summaryrefslogtreecommitdiff
path: root/lib/getopt_.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-11-17 01:59:29 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-11-17 01:59:29 +0000
commit99e10817b057cb44bb62ad18c78d0b009d208984 (patch)
treec206f7ba309acbb27a11d93fa05374a49ecfc586 /lib/getopt_.h
parentb209e757d82b173a220033b3e3ec6b0e043c83c7 (diff)
downloadcoreutils-99e10817b057cb44bb62ad18c78d0b009d208984.tar.xz
Merge from gnulib.
Diffstat (limited to 'lib/getopt_.h')
-rw-r--r--lib/getopt_.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/getopt_.h b/lib/getopt_.h
index c5c836e64..6eaa7eb91 100644
--- a/lib/getopt_.h
+++ b/lib/getopt_.h
@@ -53,6 +53,17 @@
# define optopt __GETOPT_PREFIX##optopt
#endif
+/* Standalone applications get correct prototypes for getopt_long and
+ getopt_long_only; they declare "char **argv". libc uses prototypes
+ with "char *const *argv" that are incorrect because getopt_long and
+ getopt_long_only can permute argv; this is required for backward
+ compatibility (e.g., for LSB 2.0.1). */
+#if defined __GETOPT_PREFIX && !defined __need_getopt
+# define __getopt_argv_const /* empty */
+#else
+# define __getopt_argv_const const
+#endif
+
/* If __GNU_LIBRARY__ is not already defined, either we are being used
standalone, or this is the first header included in the source file.
If we are being used with glibc, we need to include <features.h>, but
@@ -178,11 +189,11 @@ extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW;
#ifndef __need_getopt
-extern int getopt_long (int ___argc, char **___argv,
+extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
-extern int getopt_long_only (int ___argc, char **___argv,
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;