commit 8b8d747
Michael Forney
·
2026-04-03 01:02:29 +0000 UTC
parent 474195b
make: Fix some prototypes
3 files changed,
+98,
-1
1@@ -0,0 +1,72 @@
2+From c83c5ddf95c8fb3f39e03a206d34f46faadb2fe7 Mon Sep 17 00:00:00 2001
3+From: Michael Forney <mforney@mforney.org>
4+Date: Thu, 2 Apr 2026 17:54:53 -0700
5+Subject: [PATCH] Always use prototype for getopt and getenv
6+
7+---
8+ src/getopt.c | 15 ++-------------
9+ src/getopt.h | 7 -------
10+ 2 files changed, 2 insertions(+), 20 deletions(-)
11+
12+diff --git a/src/getopt.c b/src/getopt.c
13+index 7a792de8..3673aecf 100644
14+--- a/src/getopt.c
15++++ b/src/getopt.c
16+@@ -39,6 +39,8 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
17+ #endif
18+
19+ #include <stdio.h>
20++#include <stdlib.h>
21++#include <unistd.h>
22+
23+ /* Comment out all this code if we are using the GNU C Library, and are not
24+ actually compiling the library itself. This code is part of the GNU C
25+@@ -59,15 +61,6 @@ this program. If not, see <https://www.gnu.org/licenses/>. */
26+ #ifndef ELIDE_CODE
27+
28+
29+-/* This needs to come after some library #include
30+- to get __GNU_LIBRARY__ defined. */
31+-#ifdef __GNU_LIBRARY__
32+-/* Don't include stdlib.h for non-GNU C libraries because some of them
33+- contain conflicting prototypes for getopt. */
34+-# include <stdlib.h>
35+-# include <unistd.h>
36+-#endif /* GNU C library. */
37+-
38+ #ifdef VMS
39+ # include <unixlib.h>
40+ # if HAVE_STRING_H - 0
41+@@ -201,10 +194,6 @@ static char *posixly_correct;
42+ /* Avoid depending on library functions or files
43+ whose names are inconsistent. */
44+
45+-#ifndef getenv
46+-extern char *getenv ();
47+-#endif
48+-
49+ static char *
50+ my_index (const char *str, int chr)
51+ {
52+diff --git a/src/getopt.h b/src/getopt.h
53+index df18ceeb..a6cc6217 100644
54+--- a/src/getopt.h
55++++ b/src/getopt.h
56+@@ -96,14 +96,7 @@ struct option
57+ #define optional_argument 2
58+
59+ #if defined (__STDC__) && __STDC__
60+-#ifdef __GNU_LIBRARY__
61+-/* Many other libraries have conflicting prototypes for getopt, with
62+- differences in the consts, in stdlib.h. To avoid compilation
63+- errors, only prototype getopt for the GNU C library. */
64+ extern int getopt (int argc, char *const *argv, const char *shortopts);
65+-#else /* not __GNU_LIBRARY__ */
66+-extern int getopt ();
67+-#endif /* __GNU_LIBRARY__ */
68+ extern int getopt_long (int argc, char *const *argv, const char *shortopts,
69+ const struct option *longopts, int *longind);
70+ extern int getopt_long_only (int argc, char *const *argv,
71+--
72+2.49.0
73+
1@@ -0,0 +1,25 @@
2+From 4919efdefac11325db27c6a848e381a7cc28eacd Mon Sep 17 00:00:00 2001
3+From: Michael Forney <mforney@mforney.org>
4+Date: Thu, 2 Apr 2026 17:36:09 -0700
5+Subject: [PATCH] Use prototype for getenv declaration
6+
7+---
8+ lib/fnmatch.c | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+diff --git a/lib/fnmatch.c b/lib/fnmatch.c
12+index 01da376..cb1c856 100644
13+--- a/lib/fnmatch.c
14++++ b/lib/fnmatch.c
15+@@ -121,7 +121,7 @@ USA. */
16+ whose names are inconsistent. */
17+
18+ # if !defined _LIBC && !defined getenv
19+-extern char *getenv ();
20++extern char *getenv (const char *);
21+ # endif
22+
23+ # ifndef errno
24+--
25+2.49.0
26+
+1,
-1
1@@ -1 +1 @@
2-4.4.1 r0
3+4.4.1 r1