From e40673b298b8fb866c1ef91622a85a52ea09d705 Mon Sep 17 00:00:00 2001 From: Werner LEMBERG Date: Thu, 23 Jun 2005 11:33:00 +0000 Subject: [PATCH] Another round in fixing getopt problems. Hopefully the last one! This time we use the getopt stuff from gnulib and define a prefix unconditionally so that there are no collisions with any other getopt implementations. This is a slight waste of space in case we already use a GNU getopt implementation, but on the other hand it really simplifies life. * src/include/getopt.h: Use gnulib version. * src/include/getopt_int.h: Use gnulib version. * src/include/groff-getopt.h: Removed. Obsolete now. * src/include/lib.h: Regarding getopt, don't handle any platform specially; just include getopt.h. (__GETOPT_PREFIX): Define (before getopt.h). * src/include/Makefile.sub (HDRS): Updated. * src/libs/libgroff/getopt1.c, src/libs/libgroff/getopt.c: Use gnulib version. * src/libs/libgroff/Makefile.sub (EXTRA_CFLAGS): Set __GETOPT_PREFIX. * src/utils/pfbtops/pfbtops.c, src/utils/xtotroff/xtotroff.c (__GETOPT_PREFIX): Define (before getopt.h). --- ChangeLog | 30 +++++++++++++ src/include/Makefile.sub | 1 - src/include/getopt.h | 92 ++++++++++++++++++++++++++++--------- src/include/getopt_int.h | 39 ++++++++-------- src/include/groff-getopt.h | 71 ----------------------------- src/include/lib.h | 14 +----- src/libs/libgroff/Makefile.sub | 1 + src/libs/libgroff/getopt.c | 100 ++++++++++++++++++----------------------- src/libs/libgroff/getopt1.c | 60 +++++++++---------------- src/utils/pfbtops/pfbtops.c | 6 ++- src/utils/xtotroff/xtotroff.c | 5 ++- 11 files changed, 195 insertions(+), 224 deletions(-) delete mode 100644 src/include/groff-getopt.h diff --git a/ChangeLog b/ChangeLog index 886bf4c4..0ad75056 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2005-06-22 Werner LEMBERG + + Another round in fixing getopt problems. Hopefully the last one! + This time we use the getopt stuff from gnulib and define a prefix + unconditionally so that there are no collisions with any other + getopt implementations. This is a slight waste of space in case + we already use a GNU getopt implementation, but on + the other hand it really simplifies life. + + * src/include/getopt.h: Use gnulib version. + + * src/include/getopt_int.h: Use gnulib version. + + * src/include/groff-getopt.h: Removed. Obsolete now. + + * src/include/lib.h: Regarding getopt, don't handle any platform + specially; just include getopt.h. + (__GETOPT_PREFIX): Define (before getopt.h). + + * src/include/Makefile.sub (HDRS): Updated. + + * src/libs/libgroff/getopt1.c, src/libs/libgroff/getopt.c: Use + gnulib version. + + * src/libs/libgroff/Makefile.sub (EXTRA_CFLAGS): Set + __GETOPT_PREFIX. + + * src/utils/pfbtops/pfbtops.c, src/utils/xtotroff/xtotroff.c + (__GETOPT_PREFIX): Define (before getopt.h). + 2005-06-21 Werner LEMBERG * src/include/lib.h: Provide a fix for Mac OS X to not include diff --git a/src/include/Makefile.sub b/src/include/Makefile.sub index a4dfb459..58e1ac98 100644 --- a/src/include/Makefile.sub +++ b/src/include/Makefile.sub @@ -13,7 +13,6 @@ HDRS=\ getopt.h \ getopt_int.h \ gettext.h \ - groff-getopt.h \ htmlhint.h \ index.h \ lib.h \ diff --git a/src/include/getopt.h b/src/include/getopt.h index b7a026c5..a4e78cb0 100644 --- a/src/include/getopt.h +++ b/src/include/getopt.h @@ -3,20 +3,19 @@ Free Software Foundation, Inc. This file is part of the GNU C Library. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _GETOPT_H @@ -24,6 +23,64 @@ # 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 +# include +# if HAVE_UNISTD_H +# include +# endif +# undef __need_getopt +# undef getopt +# undef getopt_long +# undef getopt_long_only +# undef optarg +# undef opterr +# undef optind +# undef 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). + + 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 standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but @@ -90,7 +147,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 @@ -145,22 +202,15 @@ 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) __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; diff --git a/src/include/getopt_int.h b/src/include/getopt_int.h index d982c72d..401579fd 100644 --- a/src/include/getopt_int.h +++ b/src/include/getopt_int.h @@ -3,28 +3,27 @@ Free Software Foundation, Inc. This file is part of the GNU C Library. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #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 **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, - int __long_only); + int __long_only, int __posixly_correct); /* Reentrant versions which can handle parsing multiple argument @@ -65,7 +64,7 @@ struct _getopt_data This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. + of the list of option characters, or by calling getopt. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. @@ -88,7 +87,8 @@ struct _getopt_data REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } __ordering; - /* If the POSIXLY_CORRECT environment variable is set. */ + /* If the POSIXLY_CORRECT environment variable is set + or getopt was called. */ int __posixly_correct; @@ -111,17 +111,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 **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, - int __long_only, struct _getopt_data *__data); + int __long_only, int __posixly_correct, + struct _getopt_data *__data); -extern int _getopt_long_r (int ___argc, char *const *___argv, +extern int _getopt_long_r (int ___argc, char **___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 **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, diff --git a/src/include/groff-getopt.h b/src/include/groff-getopt.h deleted file mode 100644 index 02b7e516..00000000 --- a/src/include/groff-getopt.h +++ /dev/null @@ -1,71 +0,0 @@ -// -*- C++ -*- -/* Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc. - Written by Werner Lemberg (wl@gnu.org) - -This file is part of groff. - -groff is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -groff is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with groff; see the file COPYING. If not, write to the Free Software -Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* - This file has to be included from within lib.h instead of getopt.h - to avoid problems with picky C++ compilers. -*/ - -#ifndef _GROFF_GETOPT_H -#define _GROFF_GETOPT_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern char *optarg; -extern int optind; -extern int opterr; -extern int optopt; - -struct option -{ - const char *name; - int has_arg; - int *flag; - int val; -}; - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -extern int getopt(int, // __argc - char *const *, // __argv - const char *) // __shortopts - throw(); -extern int getopt_long(int, // __argc - char *const *, // __argv - const char *, // __shortopts - const struct option *, // __longopts - int *) // __longind - throw(); -extern int getopt_long_only(int, // __argc - char *const *, // __argv - const char *, // __shortopts - const struct option *, // __longopts - int *) // __longind - throw(); - -#ifdef __cplusplus -} -#endif - -#endif /* _GROFF_GETOPT_H */ diff --git a/src/include/lib.h b/src/include/lib.h index f6dd35fa..bb59337f 100644 --- a/src/include/lib.h +++ b/src/include/lib.h @@ -32,20 +32,8 @@ extern "C" { const char *if_to_a(int, int); } -/* stdio.h on IRIX, OSF/1, emx, UWIN, and MinGW include getopt.h */ -/* unistd.h on CYGWIN and Mac OS X include getopt.h */ - -#if !(defined(__sgi) \ - || (defined(__osf__) && defined(__alpha)) \ - || defined(_UWIN) \ - || defined(__EMX__) \ - || defined(__CYGWIN__) \ - || defined(__MINGW32__) \ - || defined(__APPLE__)) -#include -#else +#define __GETOPT_PREFIX groff_ #include -#endif #ifdef HAVE_SETLOCALE #include diff --git a/src/libs/libgroff/Makefile.sub b/src/libs/libgroff/Makefile.sub index 805292a7..e7606a82 100644 --- a/src/libs/libgroff/Makefile.sub +++ b/src/libs/libgroff/Makefile.sub @@ -1,4 +1,5 @@ LIB=groff +EXTRA_CFLAGS=-D__GETOPT_PREFIX=groff_ OBJS=\ assert.$(OBJEXT) \ change_lf.$(OBJEXT) \ diff --git a/src/libs/libgroff/getopt.c b/src/libs/libgroff/getopt.c index 9ad13a4a..bcb81c83 100644 --- a/src/libs/libgroff/getopt.c +++ b/src/libs/libgroff/getopt.c @@ -3,23 +3,22 @@ "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. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ @@ -33,25 +32,6 @@ #include -/* 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 -# 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__ @@ -82,16 +62,16 @@ # define attribute_hidden #endif -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. +/* Unlike standard Unix `getopt', functions like `getopt_long' + let the user intersperse the options with the other arguments. - As `getopt' works, it permutes the elements of ARGV so that, + As `getopt_long' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. + Using `getopt' or setting the environment variable POSIXLY_CORRECT + disables permutation. + Then the application's behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ @@ -270,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 **argv, const char *optstring, + int posixly_correct, struct _getopt_data *d) { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped @@ -281,7 +261,7 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring, d->__nextchar = NULL; - d->__posixly_correct = !!getenv ("POSIXLY_CORRECT"); + d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ @@ -375,10 +355,6 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring, `flag' field is nonzero, the value of the option's `val' field 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. - LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. @@ -387,12 +363,15 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring, recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ + long-named options. + + If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT + environment variable were set. */ int -_getopt_internal_r (int argc, char *const *argv, const char *optstring, +_getopt_internal_r (int argc, char **argv, const char *optstring, const struct option *longopts, int *longind, - int long_only, struct _getopt_data *d) + int long_only, int posixly_correct, struct _getopt_data *d) { int print_errors = d->opterr; if (optstring[0] == ':') @@ -407,7 +386,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, { if (d->optind == 0) d->optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring, d); + optstring = _getopt_initialize (argc, argv, optstring, + posixly_correct, d); d->__initialized = 1; } @@ -1155,16 +1135,17 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, } int -_getopt_internal (int argc, char *const *argv, const char *optstring, - const struct option *longopts, int *longind, int long_only) +_getopt_internal (int argc, char **argv, const char *optstring, + const struct option *longopts, int *longind, + int long_only, int posixly_correct) { int result; getopt_data.optind = optind; getopt_data.opterr = opterr; - result = _getopt_internal_r (argc, argv, optstring, longopts, - longind, long_only, &getopt_data); + result = _getopt_internal_r (argc, argv, optstring, longopts, longind, + long_only, posixly_correct, &getopt_data); optind = getopt_data.optind; optarg = getopt_data.optarg; @@ -1173,16 +1154,21 @@ _getopt_internal (int argc, char *const *argv, const char *optstring, return result; } +/* glibc gets a LSB-compliant getopt. + Standalone applications get a POSIX-compliant getopt. */ +#if _LIBC +enum { POSIXLY_CORRECT = 0 }; +#else +enum { POSIXLY_CORRECT = 1 }; +#endif + int getopt (int argc, char *const *argv, const char *optstring) { - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); + return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0, + POSIXLY_CORRECT); } -#endif /* Not ELIDE_CODE. */ #ifdef TEST diff --git a/src/libs/libgroff/getopt1.c b/src/libs/libgroff/getopt1.c index 2f75d4c2..5acd2245 100644 --- a/src/libs/libgroff/getopt1.c +++ b/src/libs/libgroff/getopt1.c @@ -3,20 +3,19 @@ Free Software Foundation, Inc. This file is part of the GNU C Library. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include @@ -31,25 +30,6 @@ #include -/* 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 -#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__ @@ -61,19 +41,20 @@ #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); + return _getopt_internal (argc, (char **) argv, options, long_options, + opt_index, 0, 0); } int -_getopt_long_r (int argc, char *const *argv, const char *options, +_getopt_long_r (int argc, char **argv, const char *options, const struct option *long_options, int *opt_index, struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 0, d); + 0, 0, d); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. @@ -82,22 +63,23 @@ _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); + return _getopt_internal (argc, (char **) argv, options, long_options, + opt_index, 1, 0); } int -_getopt_long_only_r (int argc, char *const *argv, const char *options, +_getopt_long_only_r (int argc, char **argv, const char *options, const struct option *long_options, int *opt_index, struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 1, d); + 1, 0, d); } -#endif /* Not ELIDE_CODE. */ #ifdef TEST diff --git a/src/utils/pfbtops/pfbtops.c b/src/utils/pfbtops/pfbtops.c index 81f981af..8b394d5d 100644 --- a/src/utils/pfbtops/pfbtops.c +++ b/src/utils/pfbtops/pfbtops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 2001, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1992, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. @@ -25,9 +25,11 @@ Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include -#include #include +#define __GETOPT_PREFIX groff_ +#include + #include "nonposix.h" /* Binary bytes per output line. */ diff --git a/src/utils/xtotroff/xtotroff.c b/src/utils/xtotroff/xtotroff.c index e7d1531c..dafff04b 100644 --- a/src/utils/xtotroff/xtotroff.c +++ b/src/utils/xtotroff/xtotroff.c @@ -13,10 +13,13 @@ #include #include #include -#include #include #include #include + +#define __GETOPT_PREFIX groff_ +#include + #include "XFontName.h" #include "DviChar.h" -- 2.11.4.GIT