Port sgmls non-autoconf configure script to C99

Related to:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>
This commit is contained in:
Florian Weimer 2023-04-13 18:33:41 +02:00
parent 77f027995c
commit de1d959218
2 changed files with 301 additions and 1 deletions

296
linuxdoc-tools-c99.patch Normal file
View File

@ -0,0 +1,296 @@
From 0771d5d9a49ccd2e4c10ce1fe9bb14b7f69d4081 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Thu, 13 Apr 2023 18:09:27 +0200
Subject: [PATCH] sgmls: Avoid implicit ints/function declarations in configure
Content-type: text/plain
These C features are no longer part of C99, and future compilers
will no longer support them by default, causing the build to fail.
The changes assume that the usual system headers (<stdlib.h>,
<unistd.h>) are present, but that should not be a problem on current
systems.
Submitted upstream: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1034362>
---
sgmls-1.1/configure | 60 +++++++++++++++++++++++++++++++--------------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/sgmls-1.1/configure b/sgmls-1.1/configure
index 5d3e197..e674d24 100755
--- a/sgmls-1.1/configure
+++ b/sgmls-1.1/configure
@@ -110,13 +110,15 @@ cat >doit.c <<\EOF
#include <ctype.h>
#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
static int whoops()
{
_exit(1);
}
-main()
+int main(void)
{
int c;
#ifdef isascii
@@ -213,13 +215,15 @@ else
fi
cat >doit.c <<\EOF
+#include <stdio.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
remove("foo");
- exit(0);
+ return 0;
}
EOF
@@ -231,13 +235,15 @@ else
fi
cat >doit.c <<\EOF
+#include <unistd.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
getopt(argc, argv, "v");
- exit(0);
+ return 0;
}
EOF
@@ -248,14 +254,16 @@ else
off="$off HAVE_GETOPT"
fi
-cat >doit.c <<\EOF
+cat>doit.c <<\EOF
+#include <unistd.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
access("foo", 4);
- exit(0);
+ return 0;
}
EOF
@@ -267,13 +275,15 @@ else
fi
cat >doit.c <<\EOF
+#include <unistd.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
vfork();
- exit(0);
+ return 0;
}
EOF
@@ -285,6 +295,8 @@ else
fi
cat >doit.c <<\EOF
+#include <sys/wait.h>
+int
main(argc, argv)
int argc;
char **argv;
@@ -294,7 +306,7 @@ char **argv;
int status;
waitpid(-1, &status, 0);
}
- exit(0);
+ return 0;
}
EOF
@@ -307,13 +319,14 @@ fi
cat >doit.c <<\EOF
#include <string.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
strerror(0);
- exit(0);
+ return 0;
}
EOF
@@ -326,13 +339,14 @@ fi
cat >doit.c <<\EOF
#include <strings.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
bcopy((char *)0, (char *)0, 0);
- exit(0);
+ return 0;
}
EOF
@@ -341,13 +355,14 @@ then
# Only use BSD_STRINGS if ANSI string functions don't work.
cat >doit.c <<\EOF
#include <string.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
memcpy((char *)0, (char *)0, 0);
- exit(0);
+ return 0;
}
EOF
@@ -363,13 +378,14 @@ fi
cat >doit.c <<\EOF
#include <signal.h>
+int
main(argc, argv)
int argc;
char **argv;
{
if (argc == 0)
raise(SIGINT);
- exit(0);
+ return 0;
}
EOF
@@ -382,6 +398,7 @@ fi
cat >doit.c <<\EOF
#include <stdio.h>
+int
main(argc, argv)
int argc;
char **argv;
@@ -391,7 +408,7 @@ char **argv;
fsetpos(stdin, &pos);
fgetpos(stdin, &pos);
}
- exit(0);
+ return 0;
}
EOF
@@ -407,6 +424,7 @@ cat >doit.c <<\EOF
#include <sys/types.h>
#include <sys/wait.h>
+int
main(argc, argv)
int argc;
char **argv;
@@ -423,7 +441,7 @@ char **argv;
WTERMSIG(status);
WSTOPSIG(status);
}
- exit(0);
+ return 0;
}
EOF
@@ -437,13 +455,16 @@ fi
cat >doit.c <<\EOF
#include <stdio.h>
#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
static int whoops()
{
_exit(1);
}
-main()
+int main(void)
{
char buf[30];
#ifdef SIGSEGV
@@ -470,6 +491,7 @@ fi
cat >doit.c <<\EOF
#include <nl_types.h>
+int
main(argc, argv)
int argc;
char **argv;
@@ -479,7 +501,7 @@ char **argv;
catgets(d, 1, 1, "default");
catclose(d);
}
- exit(0);
+ return 0;
}
EOF
@@ -492,9 +514,11 @@ fi
cat >doit.c <<\EOF
#include <limits.h>
+#include <stdlib.h>
char c = UCHAR_MAX;
+int
main(argc, argv)
int argc;
char **argv;
@@ -512,16 +536,16 @@ then
char_signed=
else
cat >doit.c <<\EOF
-main()
+int main(void)
{
int i;
for (i = 0; i < 512; i++) {
char c = (char)i;
if (c < 0)
- exit(1);
+ return 1;
}
- exit(0);
+ return 0;
}
EOF
--
2.39.2

View File

@ -5,11 +5,12 @@
Summary: A text formatting package based on SGML Summary: A text formatting package based on SGML
Name: linuxdoc-tools Name: linuxdoc-tools
Version: 0.9.82 Version: 0.9.82
Release: 1%{?dist} Release: 2%{?dist}
License: MIT License: MIT
Source: http://http.us.debian.org/debian/pool/main/l/linuxdoc-tools/%{name}_%{version}.orig.tar.gz Source: http://http.us.debian.org/debian/pool/main/l/linuxdoc-tools/%{name}_%{version}.orig.tar.gz
Patch01: 0001-downstream-Changed-default-papersize-to-letter.patch Patch01: 0001-downstream-Changed-default-papersize-to-letter.patch
Patch02: 0002-downstream-Added-fix-to-have-lib64-in-perl-path-on-6.patch Patch02: 0002-downstream-Added-fix-to-have-lib64-in-perl-path-on-6.patch
Patch3: linuxdoc-tools-c99.patch
Url: http://packages.qa.debian.org/l/linuxdoc-tools.html Url: http://packages.qa.debian.org/l/linuxdoc-tools.html
BuildRequires: git gcc BuildRequires: git gcc
BuildRequires: flex flex-static sgml-common jade gawk groff autoconf automake texinfo BuildRequires: flex flex-static sgml-common jade gawk groff autoconf automake texinfo
@ -102,6 +103,9 @@ exit 0
%{_mandir}/*/* %{_mandir}/*/*
%changelog %changelog
* Thu Apr 13 2023 Florian Weimer <fweimer@redhat.com> - 0.9.82-2
- Port sgmls non-autoconf configure script to C99
* Sun Feb 05 2023 Julien Rische <jrische@redhat.com> - 0.9.82-1 * Sun Feb 05 2023 Julien Rische <jrische@redhat.com> - 0.9.82-1
- New version 0.9.82 - New version 0.9.82