]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Sync from gnulib and regenerate.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 12 Nov 2004 06:00:01 +0000 (06:00 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 12 Nov 2004 06:00:01 +0000 (06:00 +0000)
config.hin
lib/ChangeLog
lib/getopt.c
lib/getopt1.c
lib/getopt_.h
lib/getopt_int.h
m4/ChangeLog
m4/getopt.m4
src/Makefile.in

index 6e419dec55bc22036524ea26d4f291d42a78da55..f630f0403a1f600d2b9c3662b8844bf965353377 100644 (file)
 # undef __EXTENSIONS__
 #endif
 
+/* Define to rpl_ if the getopt replacement functions and variables should be
+   used. */
+#undef __GETOPT_PREFIX
+
 /* Define like PROTOTYPES; this can be used by system headers. */
 #undef __PROTOTYPES
 
 /* Define to a replacement function name for getline(). */
 #undef getline
 
-/* Define to rpl_getopt if the replacement function should be used. */
-#undef getopt
-
-/* Define to rpl_getopt_long if the replacement function should be used. */
-#undef getopt_long
-
-/* Define to rpl_getopt_long_only if the replacement function should be used.
-   */
-#undef getopt_long_only
-
 /* Define to rpl_gettimeofday if the replacement function should be used. */
 #undef gettimeofday
 
 /* Define to `long' if <sys/types.h> does not define. */
 #undef off_t
 
-/* Define to rpl_optarg if the replacement variable should be used. */
-#undef optarg
-
-/* Define to rpl_optind if the replacement variable should be used. */
-#undef optind
-
-/* Define to rpl_optopt if the replacement variable should be used. */
-#undef optopt
-
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
 
index 76c16dcaf289333bf7eb8b148fdf9aaddd1f16f8..38e43daa22b860c8763c49780d1ee9617e608d13 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * getopt.c, getopt1.c, getopt_.h, getopt_int.h:
+       Sync from gnulib.
+
 2004-11-10  Paul Eggert  <eggert@cs.ucla.edu>
 
        * allocsa.h, mbswidth.c, mktime.c, readlink.c, getdate.y,
index 92207f2bd598312758ae5d07923295b925272c2d..0fa7c0688823f182287ef73814621f367b75f83f 100644 (file)
@@ -250,8 +250,8 @@ exchange (char **argv, struct _getopt_data *d)
 /* Initialize the internal data when the first call is made.  */
 
 static const char *
-_getopt_initialize (int argc, char *const *argv, const char *optstring,
-                   struct _getopt_data *d)
+_getopt_initialize (int argc, char *__getopt_argv_const *argv,
+                   const char *optstring, struct _getopt_data *d)
 {
   /* Start processing options with ARGV-element 1 (since ARGV-element 0
      is the program name); the sequence of previously skipped
@@ -356,8 +356,9 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring,
    if the `flag' field is zero.
 
    The elements of ARGV aren't really const, because we permute them.
-   But we pretend they're const in the prototype to be compatible
-   with other systems.
+   If __getopt_argv_const is defined to const, pretend they're
+   const in the prototype to be compatible with Posix.
+   But tell the truth if __getopt_argv_const is defined to empty.
 
    LONGOPTS is a vector of `struct option' terminated by an
    element containing a name which is zero.
@@ -370,7 +371,8 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring,
    long-named options.  */
 
 int
-_getopt_internal_r (int argc, char *const *argv, const char *optstring,
+_getopt_internal_r (int argc, char *__getopt_argv_const *argv,
+                   const char *optstring,
                    const struct option *longopts, int *longind,
                    int long_only, struct _getopt_data *d)
 {
@@ -1135,7 +1137,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
 }
 
 int
-_getopt_internal (int argc, char *const *argv, const char *optstring,
+_getopt_internal (int argc, char *__getopt_argv_const *argv,
+                 const char *optstring,
                  const struct option *longopts, int *longind, int long_only)
 {
   int result;
@@ -1154,7 +1157,7 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
 }
 
 int
-getopt (int argc, char *const *argv, const char *optstring)
+getopt (int argc, char *__getopt_argv_const *argv, const char *optstring)
 {
   return _getopt_internal (argc, argv, optstring,
                           (const struct option *) 0,
index 706f59c08377edabb0ff72f84d168828db20effa..a6fdee5a5762ebb53fb8dc678fbd2ecdbe80ed53 100644 (file)
 #endif
 
 int
-getopt_long (int argc, char *const *argv, const char *options,
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
             const struct option *long_options, int *opt_index)
 {
   return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
 }
 
 int
-_getopt_long_r (int argc, char *const *argv, const char *options,
+_getopt_long_r (int argc, char *__getopt_argv_const *argv, const char *options,
                const struct option *long_options, int *opt_index,
                struct _getopt_data *d)
 {
@@ -62,14 +62,16 @@ _getopt_long_r (int argc, char *const *argv, const char *options,
    instead.  */
 
 int
-getopt_long_only (int argc, char *const *argv, const char *options,
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
+                 const char *options,
                  const struct option *long_options, int *opt_index)
 {
   return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
 }
 
 int
-_getopt_long_only_r (int argc, char *const *argv, const char *options,
+_getopt_long_only_r (int argc, char *__getopt_argv_const *argv,
+                    const char *options,
                     const struct option *long_options, int *opt_index,
                     struct _getopt_data *d)
 {
index 9774110d9614c74e99d0dde3bfeedecfad333cfe..d933ce780ffcf8da19a90927c80f7a5ebf35d633 100644 (file)
 # define _GETOPT_H 1
 #endif
 
+/* Standalone applications should #define __GETOPT_PREFIX to an
+   identifier that prefixes the external functions and variables
+   defined in this header.  When this happens, include the
+   headers that might declare getopt so that they will not cause
+   confusion if included after this file.  Then systematically rename
+   identifiers so that they do not collide with the system functions
+   and variables.  Renaming avoids problems with some compilers and
+   linkers.  */
+#if defined __GETOPT_PREFIX && !defined __need_getopt
+# include <stdlib.h>
+# include <stdio.h>
+# if HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
+# undef getopt
+# undef getopt_long
+# undef getopt_long_only
+# undef optarg
+# undef opterr
+# undef optind
+# undef optopt
+# define getopt __GETOPT_PREFIX##getopt
+# define getopt_long __GETOPT_PREFIX##getopt_long
+# define getopt_long_only __GETOPT_PREFIX##getopt_long_only
+# define optarg __GETOPT_PREFIX##optarg
+# define opterr __GETOPT_PREFIX##opterr
+# define optind __GETOPT_PREFIX##optind
+# define optopt __GETOPT_PREFIX##optopt
+#endif
+
+/* The elements of the ARGV arguments to getopt aren't really const,
+   because we permute them.  For glibc, __getopt_argv_const is const
+   so that prototypes pretend the elements are const, to be compatible
+   with Posix.  However, drop this pretense for standalone
+   applications, since it's not needed there and it's safer not to lie
+   to compilers.  */
+#ifdef __GETOPT_PREFIX
+# 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
@@ -144,22 +186,16 @@ struct option
    arguments to the option '\0'.  This behavior is specific to the GNU
    `getopt'.  */
 
-#ifdef __GNU_LIBRARY__
-/* Many other libraries have conflicting prototypes for getopt, with
-   differences in the consts, in stdlib.h.  To avoid compilation
-   errors, only prototype getopt for the GNU C library.  */
-extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
+extern int getopt (int ___argc, char *__getopt_argv_const *___argv,
+                  const char *__shortopts)
        __THROW;
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
 
 #ifndef __need_getopt
-extern int getopt_long (int ___argc, char *const *___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 *const *___argv,
+extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
                             const char *__shortopts,
                             const struct option *__longopts, int *__longind)
        __THROW;
index 0c5eddeca964eab9fa1225306ab4970fafaf7e3b..158a53a09194b876b6df9caa605ee59da92a2d1b 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef _GETOPT_INT_H
 #define _GETOPT_INT_H  1
 
-extern int _getopt_internal (int ___argc, char *const *___argv,
+extern int _getopt_internal (int ___argc, char *__getopt_argv_const *___argv,
                             const char *__shortopts,
                             const struct option *__longopts, int *__longind,
                             int __long_only);
@@ -110,17 +110,18 @@ struct _getopt_data
    default values and to clear the initialization flag.  */
 #define _GETOPT_DATA_INITIALIZER       { 1, 1 }
 
-extern int _getopt_internal_r (int ___argc, char *const *___argv,
+extern int _getopt_internal_r (int ___argc, char *__getopt_argv_const *___argv,
                               const char *__shortopts,
                               const struct option *__longopts, int *__longind,
                               int __long_only, struct _getopt_data *__data);
 
-extern int _getopt_long_r (int ___argc, char *const *___argv,
+extern int _getopt_long_r (int ___argc, char *__getopt_argv_const *___argv,
                           const char *__shortopts,
                           const struct option *__longopts, int *__longind,
                           struct _getopt_data *__data);
 
-extern int _getopt_long_only_r (int ___argc, char *const *___argv,
+extern int _getopt_long_only_r (int ___argc,
+                               char *__getopt_argv_const *___argv,
                                const char *__shortopts,
                                const struct option *__longopts,
                                int *__longind,
index 3d16a9a5e2ef885f1023aa5d7cd15eb77b3e7654..6534d0877e6b71baf3c106fce02bc2686b51204d 100644 (file)
@@ -1,3 +1,7 @@
+2004-11-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * getopt.m4: Sync from gnulib.
+
 2004-11-06  Jim Meyering  <jim@meyering.net>
 
        * jm-macros.m4: Don't require gl_FUNC_FPENDING.
index c3cf64727c20c309112dd0a6896c1468a067831a..be36ddd2ed28cfa971eab6bfa7937535baa79173 100644 (file)
@@ -1,4 +1,4 @@
-# getopt.m4 serial 4
+# getopt.m4 serial 6
 dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -15,18 +15,9 @@ AC_DEFUN([gl_GETOPT_SUBSTITUTE],
   GETOPT_H=getopt.h
   AC_LIBOBJ([getopt])
   AC_LIBOBJ([getopt1])
-  AC_DEFINE([optarg], [rpl_optarg],
-    [Define to rpl_optarg if the replacement variable should be used.])
-  AC_DEFINE([optind], [rpl_optind],
-    [Define to rpl_optind if the replacement variable should be used.])
-  AC_DEFINE([optopt], [rpl_optopt],
-    [Define to rpl_optopt if the replacement variable should be used.])
-  AC_DEFINE([getopt], [rpl_getopt],
-    [Define to rpl_getopt if the replacement function should be used.])
-  AC_DEFINE([getopt_long], [rpl_getopt_long],
-    [Define to rpl_getopt_long if the replacement function should be used.])
-  AC_DEFINE([getopt_long_only], [rpl_getopt_long_only],
-    [Define to rpl_getopt_long_only if the replacement function should be used.])
+  AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
+    [Define to rpl_ if the getopt replacement functions and variables
+     should be used.])
   AC_SUBST([GETOPT_H])
 ])
 
index d971fb03a50efdd90daa81df80b9fdb9225c6195..e096db9589f8f505e7b4aa99ca25afa2b0bf6069 100644 (file)
@@ -940,7 +940,7 @@ uninstall-binPROGRAMS:
        done
 
 clean-binPROGRAMS:
-       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+       -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) > /dev/null 2>&1 || /bin/rm -f $(bin_PROGRAMS)
 
 installcheck-binPROGRAMS: $(bin_PROGRAMS)
        bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \