diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-08-20 02:10:15 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-08-20 02:10:15 +0000 |
commit | 529a7c21fd1950e3a1e5a4ec429b6e2c12f619d8 (patch) | |
tree | 9a4e62d84b9123b7ed14fbe3f071e1d5436e6487 | |
parent | 463f2060b7f399676d25a598aa4ec45ec8e3cb07 (diff) | |
download | coreutils-529a7c21fd1950e3a1e5a4ec429b6e2c12f619d8.tar.xz |
Sync getopt from gnulib.
-rw-r--r-- | lib/.cvsignore | 1 | ||||
-rw-r--r-- | lib/ChangeLog | 11 | ||||
-rw-r--r-- | lib/Makefile.am | 12 | ||||
-rw-r--r-- | lib/getopt.c | 22 | ||||
-rw-r--r-- | lib/getopt1.c | 20 | ||||
-rw-r--r-- | lib/getopt_.h (renamed from lib/getopt.h) | 2 | ||||
-rw-r--r-- | lib/getopt_int.h | 6 | ||||
-rw-r--r-- | m4/ChangeLog | 4 | ||||
-rw-r--r-- | m4/getopt.m4 | 42 |
9 files changed, 70 insertions, 50 deletions
diff --git a/lib/.cvsignore b/lib/.cvsignore index c5a94a33c..b03b347c3 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -4,6 +4,7 @@ alloca.h charset.alias getdate.c getdate.tab.c +getopt.h fnmatch.h fts.h lstat.c diff --git a/lib/ChangeLog b/lib/ChangeLog index 97296b64b..acbaa7bbc 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,14 @@ +2004-08-19 Paul Eggert <eggert@cs.ucla.edu> + + * getopt.c, getopt1.c: Sync from gnulib. + * getopt_.h: Renamed from getopt.h (this syncs from gnulib). + * Makefile.am (libfetish_a_SOURCES): Remove getopt.c, getopt.h, + getopt1.c, getopt_int.h. + (BUILT_SOURCES, EXTRA_DIST, all-local, $(lib_OBJECTS), getopt.h, + MOSTLYCLEANFILES): Add current gnulib snippet for getopt. + * .cppi-disable: Add getopt_.h, getopt_int.h. + * .cvsignore: Add getopt.h. + 2004-08-18 Paul Eggert <eggert@cs.ucla.edu> * userspec.c: Don't use <alloca.h>, so that we don't use alloca on diff --git a/lib/Makefile.am b/lib/Makefile.am index 386194c65..e5a776b72 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -33,7 +33,6 @@ libfetish_a_SOURCES = \ posixtm.c posixtm.h \ posixver.c posixver.h \ strftime.c strftime.h \ - getopt.c getopt.h getopt1.c getopt_int.h \ hash.c hash.h \ hash-pjw.c hash-pjw.h \ __fpending.h \ @@ -239,3 +238,14 @@ fnmatch.h: fnmatch_.h cp $(srcdir)/fnmatch_.h $@-t mv $@-t $@ MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t + +BUILT_SOURCES += $(GETOPT_H) +EXTRA_DIST += getopt_.h getopt_int.h + +# We need the following in order to create an <getopt.h> when the system +# doesn't have one that works with the given compiler. +all-local $(lib_OBJECTS): $(GETOPT_H) +getopt.h: getopt_.h + cp $(srcdir)/getopt_.h $@-t + mv $@-t $@ +MOSTLYCLEANFILES += getopt.h getopt.h-t diff --git a/lib/getopt.c b/lib/getopt.c index afc284843..95b3604f8 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -3,7 +3,7 @@ "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004 - Free Software Foundation, Inc. + Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -32,25 +32,6 @@ #include <stdio.h> -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include <gnu-versions.h> -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif -#endif - -#ifndef ELIDE_CODE - - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ @@ -1181,7 +1162,6 @@ getopt (int argc, char *const *argv, const char *optstring) 0); } -#endif /* Not ELIDE_CODE. */ #ifdef TEST diff --git a/lib/getopt1.c b/lib/getopt1.c index 7671eba37..706f59c08 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -30,25 +30,6 @@ #include <stdio.h> -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ @@ -96,7 +77,6 @@ _getopt_long_only_r (int argc, char *const *argv, const char *options, 1, d); } -#endif /* Not ELIDE_CODE. */ #ifdef TEST diff --git a/lib/getopt.h b/lib/getopt_.h index 9774110d9..c61768c69 100644 --- a/lib/getopt.h +++ b/lib/getopt_.h @@ -89,7 +89,7 @@ extern int optopt; The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. + optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but diff --git a/lib/getopt_int.h b/lib/getopt_int.h index 36b711eb7..0c5eddeca 100644 --- a/lib/getopt_int.h +++ b/lib/getopt_int.h @@ -18,7 +18,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_INT_H -# define _GETOPT_INT_H 1 +#define _GETOPT_INT_H 1 extern int _getopt_internal (int ___argc, char *const *___argv, const char *__shortopts, @@ -100,7 +100,7 @@ struct _getopt_data int __first_nonopt; int __last_nonopt; -# if defined _LIBC && defined USE_NONOPTION_FLAGS +#if defined _LIBC && defined USE_NONOPTION_FLAGS int __nonoption_flags_max_len; int __nonoption_flags_len; # endif @@ -108,7 +108,7 @@ struct _getopt_data /* The initializer is necessary to set OPTIND and OPTERR to their default values and to clear the initialization flag. */ -# define _GETOPT_DATA_INITIALIZER { 1, 1 } +#define _GETOPT_DATA_INITIALIZER { 1, 1 } extern int _getopt_internal_r (int ___argc, char *const *___argv, const char *__shortopts, diff --git a/m4/ChangeLog b/m4/ChangeLog index 3f27621cb..cb5e17bc7 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2004-08-19 Paul Eggert <eggert@cs.ucla.edu> + + * getopt.m4: Sync from gnulib. + 2004-08-11 Paul Eggert <eggert@cs.ucla.edu> * obstack.m4 (gl_PREREQ_OBSTACK): Require diff --git a/m4/getopt.m4 b/m4/getopt.m4 index df602b985..5ab357023 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 @@ -1,13 +1,47 @@ -# getopt.m4 serial 2 -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# getopt.m4 serial 3 +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 dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. +# The getopt module assume you want GNU getopt, with getopt_long etc, +# rather than vanilla POSIX getopt. This means your your code should +# always include <getopt.h> for the getopt prototypes. + +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_SUBST([GETOPT_H]) +]) + AC_DEFUN([gl_GETOPT], [ - dnl Prerequisites of lib/getopt.c. - : + gl_PREREQ_GETOPT + + GETOPT_H= + AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) + AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) + + if test -n "$GETOPT_H"; then + gl_GETOPT_SUBSTITUTE + fi ]) + +# Prerequisites of lib/getopt*. +AC_DEFUN([gl_PREREQ_GETOPT], [:]) |