diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-11-23 21:03:45 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-11-23 21:03:45 +0000 |
commit | 8e9bd230134bf5fa7004ff37e1a129d3efffbf1e (patch) | |
tree | 56e6d057d318d7354cad412e8c84b01875661bb3 /lib | |
parent | 398491f38184dc9065d81e91833661ce781d4f8b (diff) | |
download | coreutils-8e9bd230134bf5fa7004ff37e1a129d3efffbf1e.tar.xz |
Sync from gnulib.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 15 | ||||
-rw-r--r-- | lib/getopt_.h | 41 |
2 files changed, 43 insertions, 13 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 2bb19ebf7..7d547fa26 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -6,9 +6,22 @@ as utime and utimens. * utimens.h (futimens): New decl. +2004-11-23 Sergey Poznyakoff <gray@Mirddin.farlep.net> + + * getopt_.h: Re-addition of __getopt_argv_const caused + redefinition warnings. To avoid them, include the defines + in `#if !defined __need_getopt ... #endif'. The only place + where __getopt_argv_const is used is in definitions + of getopt_long and getopt_long_only below, which are as well + protected by `#ifndef __need_getopt'. + [defined __GETOPT_PREFIX && !defined __need_getopt]: Undef + __need_getopt after including <stdio.h> and <unistd.h> These + headers might have defined it. + 2004-11-23 Jim Meyering <jim@meyering.net> - * closeout.c: Revert last change, since it seems EBADF is always defined. + * closeout.c: Revert last change, since it seems EBADF is always + defined. 2004-11-22 Jim Meyering <jim@meyering.net> diff --git a/lib/getopt_.h b/lib/getopt_.h index 6eaa7eb91..83ac8b128 100644 --- a/lib/getopt_.h +++ b/lib/getopt_.h @@ -37,6 +37,7 @@ # if HAVE_UNISTD_H # include <unistd.h> # endif +# undef __need_getopt # undef getopt # undef getopt_long # undef getopt_long_only @@ -44,24 +45,40 @@ # 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 +# define __GETOPT_CONCAT(x, y) x ## y +# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) +# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) +# define getopt __GETOPT_ID (getopt) +# define getopt_long __GETOPT_ID (getopt_long) +# define getopt_long_only __GETOPT_ID (getopt_long_only) +# define optarg __GETOPT_ID (optarg) +# define opterr __GETOPT_ID (opterr) +# define optind __GETOPT_ID (optind) +# define optopt __GETOPT_ID (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 + compatibility (e.g., for LSB 2.0.1). + + This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt', + but it caused redefinition warnings if both unistd.h and getopt.h were + included, since unistd.h includes getopt.h having previously defined + __need_getopt. + + The only place where __getopt_argv_const is used is in definitions + of getopt_long and getopt_long_only below, but these are visible + only if __need_getopt is not defined, so it is quite safe to rewrite + the conditional as follows: +*/ +#if !defined __need_getopt +# if defined __GETOPT_PREFIX +# define __getopt_argv_const /* empty */ +# else +# define __getopt_argv_const const +# endif #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used |