* include/features.h: If no feature selection given and we select
authorUlrich Drepper <drepper@redhat.com>
Thu, 26 Feb 2009 01:22:06 +0000 (01:22 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 26 Feb 2009 01:22:06 +0000 (01:22 +0000)
by default a POSIX mode, also define __USE_POSIX_IMPLICITLY.
* posix/Versions: Export __posix_getopt.
* posix/getopt.c (_getopt_initialize): Take additional parameter.
Use it to alternatively initialize __posixly_correct.
(_getopt_internal_r): Take addition parameter.  Pass on to
_getopt_initialize.
(_getopt_internal): Take addition parameter.  Pass on to
_getopt_internal_r.
(getopt): Pass additional zero to _getopt_internal.
(__posix_getopt): New function.
* posix/getopt.h: Add redirection for getopt.
* posix/getopt1.c (getopt_long): Pass additional zero to
_getopt_internal.
(getopt_long_only): Likewise.
(_getopt_long_r): Pass additional zero to _getopt_internal_r.
(_getopt_long_only_r): Likewise.
* posix/getopt_int.h: Adjust declarations of _getopt_internal and
_getopt_internal_r.

ChangeLog
include/features.h
posix/Versions
posix/getopt.c
posix/getopt.h
posix/getopt1.c
posix/getopt_int.h

index fcbcde888c558b050b8adec981d22a78e6f3e678..a4240e039a036470f7555d3c450a8673be291f2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2009-02-25  Ulrich Drepper  <drepper@redhat.com>
+
+       * include/features.h: If no feature selection given and we select
+       by default a POSIX mode, also define __USE_POSIX_IMPLICITLY.
+       * posix/Versions: Export __posix_getopt.
+       * posix/getopt.c (_getopt_initialize): Take additional parameter.
+       Use it to alternatively initialize __posixly_correct.
+       (_getopt_internal_r): Take addition parameter.  Pass on to
+       _getopt_initialize.
+       (_getopt_internal): Take addition parameter.  Pass on to
+       _getopt_internal_r.
+       (getopt): Pass additional zero to _getopt_internal.
+       (__posix_getopt): New function.
+       * posix/getopt.h: Add redirection for getopt.
+       * posix/getopt1.c (getopt_long): Pass additional zero to
+       _getopt_internal.
+       (getopt_long_only): Likewise.
+       (_getopt_long_r): Pass additional zero to _getopt_internal_r.
+       (_getopt_long_only_r): Likewise.
+       * posix/getopt_int.h: Adjust declarations of _getopt_internal and
+       _getopt_internal_r.
+
 2009-02-24  Ulrich Drepper  <drepper@redhat.com>
 
        * bits/confname.h: Define _SC_TRACE_EVENT_NAME_MAX, _SC_TRACE_NAME_MAX,
index 3a44e38a2c2e650afb22605615789a51537173bc..eb05b0fb454284003996e846104186fafd6a79eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1993,1995-2006,2007 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-2006,2007,2009 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
 # else
 #  define _POSIX_C_SOURCE      200112L
 # endif
+# define __USE_POSIX_IMPLICITLY        1
 #endif
 
 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
index f73ff4a85a52f6c001297b8e12eaf7b5bfec63d7..10625f19e1ff5bd1aebc32661f451276b22107fc 100644 (file)
@@ -128,6 +128,9 @@ libc {
   GLIBC_2.7 {
     __sched_cpualloc; __sched_cpufree;
   }
+  GLIBC_2.10 {
+    __posix_getopt;
+  }
   GLIBC_PRIVATE {
     __libc_fork; __libc_pwrite;
   }
index 965bfdd3ac955c2e96425d1e55a68fe4ebdba955..a7f0b548579225a3a923499b1d8c38c309156b93 100644 (file)
@@ -2,7 +2,7 @@
    NOTE: getopt is part of the C library, so if you don't know what
    "Keep this file name-space clean" means, talk to drepper@gnu.org
    before changing it!
-   Copyright (C) 1987-1996,1998-2004,2008 Free Software Foundation, Inc.
+   Copyright (C) 1987-1996,1998-2004,2008,2009 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
@@ -270,7 +270,7 @@ exchange (char **argv, struct _getopt_data *d)
 
 static const char *
 _getopt_initialize (int argc, char *const *argv, const char *optstring,
-                   struct _getopt_data *d)
+                   struct _getopt_data *d, int posixly_correct)
 {
   /* Start processing options with ARGV-element 1 (since ARGV-element 0
      is the program name); the sequence of previously skipped
@@ -280,7 +280,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.  */
 
@@ -391,7 +391,7 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring,
 int
 _getopt_internal_r (int argc, char *const *argv, const char *optstring,
                    const struct option *longopts, int *longind,
-                   int long_only, struct _getopt_data *d)
+                   int long_only, struct _getopt_data *d, int posixly_correct)
 {
   int print_errors = d->opterr;
   if (optstring[0] == ':')
@@ -406,7 +406,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, d,
+                                     posixly_correct);
       d->__initialized = 1;
     }
 
@@ -1111,7 +1112,8 @@ _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)
+                 const struct option *longopts, int *longind, int long_only,
+                 int posixly_correct)
 {
   int result;
 
@@ -1119,7 +1121,8 @@ _getopt_internal (int argc, char *const *argv, const char *optstring,
   getopt_data.opterr = opterr;
 
   result = _getopt_internal_r (argc, argv, optstring, longopts,
-                              longind, long_only, &getopt_data);
+                              longind, long_only, &getopt_data,
+                              posixly_correct);
 
   optind = getopt_data.optind;
   optarg = getopt_data.optarg;
@@ -1134,9 +1137,20 @@ getopt (int argc, char *const *argv, const char *optstring)
   return _getopt_internal (argc, argv, optstring,
                           (const struct option *) 0,
                           (int *) 0,
-                          0);
+                          0, 0);
 }
 
+#ifdef _LIBC
+int
+__posix_getopt (int argc, char *const *argv, const char *optstring)
+{
+  return _getopt_internal (argc, argv, optstring,
+                          (const struct option *) 0,
+                          (int *) 0,
+                          0, 1);
+}
+#endif
+
 #endif /* Not ELIDE_CODE.  */
 \f
 #ifdef TEST
index b7a026c535fec0c1f3bcd2df8e23c594833ecb2b..ff0251dec0bb3dbd884d589c87449251a30bc15f 100644 (file)
@@ -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,2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -151,6 +151,22 @@ struct option
    errors, only prototype getopt for the GNU C library.  */
 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
        __THROW;
+
+# if defined __need_getopt && defined __USE_POSIX2 \
+  && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
+/* The GNU getopt has more functionality than the standard version.  The
+   additional functionality can be disable at runtime.  This redirection
+   helps to also do this at runtime.  */
+#  ifdef __REDIRECT
+  extern int __REDIRECT (getopt, (int ___argc, char *const *___argv,
+                                 const char *__shortopts),
+                        __posix_getopt) __THROW;
+#  else
+extern int __posix_getopt (int ___argc, char *const *___argv,
+                          const char *__shortopts) __THROW;
+#   define getopt __posix_getopt
+#  endif
+# endif
 #else /* not __GNU_LIBRARY__ */
 extern int getopt ();
 #endif /* __GNU_LIBRARY__ */
index 2f75d4c2ee71e29cbc70390a0ff80b455344ecf5..4818ea122a96bb75befd957c18087d97debfe449 100644 (file)
@@ -1,6 +1,5 @@
 /* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004
-     Free Software Foundation, Inc.
+   Copyright (C) 1987-1994,1996-1998,2004,2009 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
@@ -64,7 +63,7 @@ int
 getopt_long (int argc, char *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, argv, options, long_options, opt_index, 0, 0);
 }
 
 int
@@ -73,7 +72,7 @@ _getopt_long_r (int argc, char *const *argv, const char *options,
                struct _getopt_data *d)
 {
   return _getopt_internal_r (argc, argv, options, long_options, opt_index,
-                            0, d);
+                            0, d, 0);
 }
 
 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
@@ -85,7 +84,7 @@ int
 getopt_long_only (int argc, char *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, argv, options, long_options, opt_index, 1, 0);
 }
 
 int
@@ -94,7 +93,7 @@ _getopt_long_only_r (int argc, char *const *argv, const char *options,
                     struct _getopt_data *d)
 {
   return _getopt_internal_r (argc, argv, options, long_options, opt_index,
-                            1, d);
+                            1, d, 0);
 }
 
 #endif /* Not ELIDE_CODE.  */
index d982c72d9ee9b162016fbdbccc5a54e9f57ae22c..d44ee064a8d8895cbb7fb842d9f96c9e2801a90d 100644 (file)
@@ -1,5 +1,5 @@
 /* Internal declarations for getopt.
-   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+   Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -24,7 +24,7 @@
 extern int _getopt_internal (int ___argc, char *const *___argv,
                             const char *__shortopts,
                             const struct option *__longopts, int *__longind,
-                            int __long_only);
+                            int __long_only, int posixly_correct);
 
 \f
 /* Reentrant versions which can handle parsing multiple argument
@@ -114,7 +114,8 @@ struct _getopt_data
 extern int _getopt_internal_r (int ___argc, char *const *___argv,
                               const char *__shortopts,
                               const struct option *__longopts, int *__longind,
-                              int __long_only, struct _getopt_data *__data);
+                              int __long_only, struct _getopt_data *__data,
+                              int posixly_correct);
 
 extern int _getopt_long_r (int ___argc, char *const *___argv,
                           const char *__shortopts,