groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ./ChangeLog src/include/Makefile.sub src/...


From: Werner LEMBERG
Subject: [Groff-commit] groff ./ChangeLog src/include/Makefile.sub src/...
Date: Thu, 23 Jun 2005 07:33:01 -0400

CVSROOT:        /cvsroot/groff
Module name:    groff
Branch:         
Changes by:     Werner LEMBERG <address@hidden> 05/06/23 11:33:00

Modified files:
        .              : ChangeLog 
        src/include    : Makefile.sub getopt.h getopt_int.h lib.h 
        src/libs/libgroff: Makefile.sub getopt.c getopt1.c 
        src/utils/pfbtops: pfbtops.c 
        src/utils/xtotroff: xtotroff.c 
Removed files:
        src/include    : groff-getopt.h 

Log message:
        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).

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/ChangeLog.diff?tr1=1.836&tr2=1.837&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/include/Makefile.sub.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/include/getopt.h.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/include/getopt_int.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/include/lib.h.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/libs/libgroff/Makefile.sub.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/libs/libgroff/getopt.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/libs/libgroff/getopt1.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/utils/pfbtops/pfbtops.c.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/utils/xtotroff/xtotroff.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: groff/ChangeLog
diff -u groff/ChangeLog:1.836 groff/ChangeLog:1.837
--- groff/ChangeLog:1.836       Wed Jun 22 04:56:56 2005
+++ groff/ChangeLog     Thu Jun 23 11:33:00 2005
@@ -1,3 +1,33 @@
+2005-06-22  Werner LEMBERG  <address@hidden>
+
+       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  <address@hidden>
 
        * src/include/lib.h: Provide a fix for Mac OS X to not include
Index: groff/src/include/Makefile.sub
diff -u groff/src/include/Makefile.sub:1.16 groff/src/include/Makefile.sub:1.17
--- groff/src/include/Makefile.sub:1.16 Thu Jun 16 09:47:48 2005
+++ groff/src/include/Makefile.sub      Thu Jun 23 11:33:00 2005
@@ -13,7 +13,6 @@
   getopt.h \
   getopt_int.h \
   gettext.h \
-  groff-getopt.h \
   htmlhint.h \
   index.h \
   lib.h \
Index: groff/src/include/getopt.h
diff -u groff/src/include/getopt.h:1.8 groff/src/include/getopt.h:1.9
--- groff/src/include/getopt.h:1.8      Thu Jun 16 09:47:48 2005
+++ groff/src/include/getopt.h  Thu Jun 23 11:33:00 2005
@@ -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 <stdlib.h>
+# include <stdio.h>
+# if HAVE_UNISTD_H
+#  include <unistd.h>
+# 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 <features.h>, but
@@ -90,7 +147,7 @@
    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 @@
    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;
Index: groff/src/include/getopt_int.h
diff -u groff/src/include/getopt_int.h:1.3 groff/src/include/getopt_int.h:1.4
--- groff/src/include/getopt_int.h:1.3  Thu Jun 16 09:47:48 2005
+++ groff/src/include/getopt_int.h      Thu Jun 23 11:33:00 2005
@@ -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 @@
      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 @@
       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 @@
    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,
Index: groff/src/include/lib.h
diff -u groff/src/include/lib.h:1.39 groff/src/include/lib.h:1.40
--- groff/src/include/lib.h:1.39        Wed Jun 22 04:56:57 2005
+++ groff/src/include/lib.h     Thu Jun 23 11:33:00 2005
@@ -32,20 +32,8 @@
   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 <groff-getopt.h>
-#else
+#define __GETOPT_PREFIX groff_
 #include <getopt.h>
-#endif
 
 #ifdef HAVE_SETLOCALE
 #include <locale.h>
Index: groff/src/libs/libgroff/Makefile.sub
diff -u groff/src/libs/libgroff/Makefile.sub:1.23 
groff/src/libs/libgroff/Makefile.sub:1.24
--- groff/src/libs/libgroff/Makefile.sub:1.23   Sat Apr  2 12:49:11 2005
+++ groff/src/libs/libgroff/Makefile.sub        Thu Jun 23 11:33:00 2005
@@ -1,4 +1,5 @@
 LIB=groff
+EXTRA_CFLAGS=-D__GETOPT_PREFIX=groff_
 OBJS=\
   assert.$(OBJEXT) \
   change_lf.$(OBJEXT) \
Index: groff/src/libs/libgroff/getopt.c
diff -u groff/src/libs/libgroff/getopt.c:1.9 
groff/src/libs/libgroff/getopt.c:1.10
--- groff/src/libs/libgroff/getopt.c:1.9        Thu Jun 16 09:47:49 2005
+++ groff/src/libs/libgroff/getopt.c    Thu Jun 23 11:33:00 2005
@@ -3,23 +3,22 @@
    "Keep this file name-space clean" means, talk to address@hidden
    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 <stdio.h>.
    Ditto for AIX 3.2 and <stdlib.h>.  */
@@ -33,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__
@@ -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 @@
 /* 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 @@
 
   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 @@
    `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 @@
    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 @@
     {
       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 @@
 }
 
 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 @@
   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
 
Index: groff/src/libs/libgroff/getopt1.c
diff -u groff/src/libs/libgroff/getopt1.c:1.7 
groff/src/libs/libgroff/getopt1.c:1.8
--- groff/src/libs/libgroff/getopt1.c:1.7       Thu Jun 16 09:47:49 2005
+++ groff/src/libs/libgroff/getopt1.c   Thu Jun 23 11:33:00 2005
@@ -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 <config.h>
@@ -31,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__
@@ -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 @@
    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
 
Index: groff/src/utils/pfbtops/pfbtops.c
diff -u groff/src/utils/pfbtops/pfbtops.c:1.15 
groff/src/utils/pfbtops/pfbtops.c:1.16
--- groff/src/utils/pfbtops/pfbtops.c:1.15      Thu May 26 21:02:01 2005
+++ groff/src/utils/pfbtops/pfbtops.c   Thu Jun 23 11:33:00 2005
@@ -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 (address@hidden)
 
 This file is part of groff.
@@ -25,9 +25,11 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <limits.h>
 
+#define __GETOPT_PREFIX groff_
+#include <getopt.h>
+
 #include "nonposix.h"
 
 /* Binary bytes per output line. */
Index: groff/src/utils/xtotroff/xtotroff.c
diff -u groff/src/utils/xtotroff/xtotroff.c:1.3 
groff/src/utils/xtotroff/xtotroff.c:1.4
--- groff/src/utils/xtotroff/xtotroff.c:1.3     Sun Apr 24 06:10:55 2005
+++ groff/src/utils/xtotroff/xtotroff.c Thu Jun 23 11:33:00 2005
@@ -13,10 +13,13 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <string.h>
 #include <fcntl.h>
 #include <limits.h>
+
+#define __GETOPT_PREFIX groff_
+#include <getopt.h>
+
 #include "XFontName.h"
 #include "DviChar.h"
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]