X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetopt_.h;h=27fce3dc799e0012f8033608cb1b8307bdb9d695;hb=44d6eead9ba864662836a9f9d95913b4e0cb2a3b;hp=efae5aa69526eae2d561068b5a7b0f43a36d6c21;hpb=d62116ed81818e4abd07795c1595af5c5dece6fd;p=gnulib.git diff --git a/lib/getopt_.h b/lib/getopt_.h index efae5aa69..27fce3dc7 100644 --- a/lib/getopt_.h +++ b/lib/getopt_.h @@ -1,5 +1,5 @@ /* Declarations for getopt. - Copyright (C) 1989-1994,1996-1999,2001,2003,2004 + Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _GETOPT_H @@ -34,9 +34,8 @@ #if defined __GETOPT_PREFIX && !defined __need_getopt # include # include -# if HAVE_UNISTD_H -# include -# endif +# include +# undef __need_getopt # undef getopt # undef getopt_long # undef getopt_long_only @@ -60,11 +59,24 @@ 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 @@ -184,9 +196,10 @@ struct option scanning, explicitly telling `getopt' that there are no more options. - If OPTS begins with `--', then non-option arguments are treated as - arguments to the option '\0'. This behavior is specific to the GNU - `getopt'. */ + If OPTS begins with `-', then non-option arguments are treated as + arguments to the option '\1'. This behavior is specific to the GNU + `getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in + the environment, then do not permute arguments. */ extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) __THROW;