1995-02-18 01:27:10 +00:00
|
|
|
/* Declarations for getopt.
|
2017-01-01 00:14:16 +00:00
|
|
|
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
1997-05-07 15:31:21 +00:00
|
|
|
This file is part of the GNU C Library.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-11-15 04:08:00 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
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.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-11-15 04:08:00 +00:00
|
|
|
The GNU C Library 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
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
#ifndef _GETOPT_H
|
1998-09-23 15:28:54 +00:00
|
|
|
|
|
|
|
#ifndef __need_getopt
|
|
|
|
# define _GETOPT_H 1
|
|
|
|
#endif
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1999-07-18 00:19:18 +00:00
|
|
|
/* 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
|
|
|
|
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
|
|
|
not defined, include <ctype.h>, which will pull in <features.h> for us
|
|
|
|
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
|
|
|
doesn't flood the namespace with stuff the way some other headers do.) */
|
|
|
|
#if !defined __GNU_LIBRARY__
|
|
|
|
# include <ctype.h>
|
|
|
|
#endif
|
1999-06-23 12:58:33 +00:00
|
|
|
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
#ifndef __GNUC_PREREQ
|
|
|
|
# define __GNUC_PREREQ(maj, min) (0)
|
|
|
|
#endif
|
|
|
|
|
Update.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* grp/Makefile (CFLAGS-getgrgid_r.c, CFLAGS-getgrnam_r.c,
CFLAGS-fgetgrent.c, CFLAGS-fgetgrent_r.c, CFLAGS-putgrent.c,
CFLAGS-initgroups.c, CFLAGS-getgrgid.c): Add -fexceptions.
* inet/Makefile (CFLAGS-either_ntoh.c, CFLAGS-either_hton.c,
CFLAGS-getnetgrent.c, CFLAGS-getnetgrent_r.c): Likewise.
* io/Makefile (CFLAGS-posix_fallocate.c, CFLAGS-posix_fallocate64.c):
Likewise.
* misc/Makefile (CFLAGS-err.c): Likewise.
* posix/Makefile (CFLAGS-getaddrinfo.c, CFLAGS-spawn.c,
CFLAGS-spawnp.c, CFLAGS-spawni.c, CFLAGS-pause.c, CFLAGS-glob.c,
CFLAGS-glob64.c): Likewise.
* pwd/Makefile (CFLAGS-getpw.c): Likewise.
* shadow/Makefile (CFLAGS-fgetspent.c, CFLAGS-fgetspent_r.c,
CFLAGS-putspent.c, CFLAGS-getspnam.c, CFLAGS-getspnam_r.c): Likewise.
* stdio-common/Makefile (CFLAGS-cuserid.c): Likewise.
* sunrpc/Makefile (CFLAGS-openchild.c): Likewise.
* stdlib/Makefile (CFLAGS-mkstemp.c): Remove definition.
* libio/stdio.h: Remove __THROW from cuserid prototype.
* locale/loadarchive.c: Use only non-cancelable interfaces.
* resolv/herror.c (herror): Likewise.
* malloc/hooks.c: Before using IO stream mark stream so it uses
only non-cancelable interfaces.
* malloc/malloc.c: Likewise.
* posix/getopt.c: Likewise.
2003-09-11 Jakub Jelinek <jakub@redhat.com>
* Makerules (LDFLAGS-c.so): Remove -u __register_frame.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* stdio-common/stdio_ext.h: Mark most functions with __THROW.
* misc/err.h: Remove __THROW from all prototypes.
* posix/getopt.h (__THROW): Define if not already defined. Add
__THROW to the getopt functions.
2003-09-11 Ulrich Drepper <drepper@redhat.com>
* io/Makefile (CFLAGS-lockf.c): Add -fexceptions.
(CFLAGS-fts.c): Likewise.
* io/fcntl.h: Remove __THROW from lockf prototypes.
* io/fts.h: Remove most __THROW.
2003-09-12 22:37:19 +00:00
|
|
|
#ifndef __THROW
|
|
|
|
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
|
|
|
# define __THROW throw ()
|
|
|
|
# else
|
|
|
|
# define __THROW
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
#ifndef __nonnull
|
|
|
|
# if __GNUC_PREREQ (3, 3)
|
|
|
|
# define __nonnull(params) __attribute__ ((__nonnull__ params))
|
|
|
|
# else
|
|
|
|
# define __nonnull(params)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
/* For communication from 'getopt' to the caller.
|
|
|
|
When 'getopt' finds an option that takes an argument,
|
1995-02-18 01:27:10 +00:00
|
|
|
the argument value is returned here.
|
2017-03-31 11:39:55 +00:00
|
|
|
Also, when 'ordering' is RETURN_IN_ORDER,
|
1995-02-18 01:27:10 +00:00
|
|
|
each non-option ARGV-element is returned here. */
|
|
|
|
|
|
|
|
extern char *optarg;
|
|
|
|
|
|
|
|
/* Index in ARGV of the next element to be scanned.
|
|
|
|
This is used for communication to and from the caller
|
2017-03-31 11:39:55 +00:00
|
|
|
and for communication between successive calls to 'getopt'.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
On entry to 'getopt', zero means this is the first call; initialize.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
When 'getopt' returns -1, this is the index of the first of the
|
1995-02-18 01:27:10 +00:00
|
|
|
non-option elements that the caller should itself scan.
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
Otherwise, 'optind' communicates from one call to the next
|
1995-02-18 01:27:10 +00:00
|
|
|
how much of ARGV has been scanned so far. */
|
|
|
|
|
|
|
|
extern int optind;
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
/* Callers store zero here to inhibit the error message 'getopt' prints
|
1995-02-18 01:27:10 +00:00
|
|
|
for unrecognized options. */
|
|
|
|
|
|
|
|
extern int opterr;
|
|
|
|
|
|
|
|
/* Set to an option character which was unrecognized. */
|
|
|
|
|
|
|
|
extern int optopt;
|
|
|
|
|
1998-09-23 15:28:54 +00:00
|
|
|
#ifndef __need_getopt
|
1995-02-18 01:27:10 +00:00
|
|
|
/* Describe the long-named options requested by the application.
|
|
|
|
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
2017-03-31 11:39:55 +00:00
|
|
|
of 'struct option' terminated by an element containing a name which is
|
1995-02-18 01:27:10 +00:00
|
|
|
zero.
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
The field 'has_arg' is:
|
1995-02-18 01:27:10 +00:00
|
|
|
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.
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
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
|
1995-02-18 01:27:10 +00:00
|
|
|
left unchanged if the option is not found.
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
To have a long-named option do something other than set an 'int' to
|
|
|
|
a compiled-in constant, such as set a value from 'optarg', set the
|
|
|
|
option's 'flag' field to zero and its 'val' field to a nonzero
|
1995-02-18 01:27:10 +00:00
|
|
|
value (the equivalent single-letter option character, if there is
|
2017-03-31 11:39:55 +00:00
|
|
|
one). For long options that have a zero 'flag' field, 'getopt'
|
|
|
|
returns the contents of the 'val' field. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
struct option
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
/* has_arg can't be an enum because some compilers complain about
|
|
|
|
type mismatches in all the code that assumes it is an int. */
|
|
|
|
int has_arg;
|
|
|
|
int *flag;
|
|
|
|
int val;
|
|
|
|
};
|
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
/* Names for the values of the 'has_arg' field of 'struct option'. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1998-09-11 12:14:37 +00:00
|
|
|
# define no_argument 0
|
|
|
|
# define required_argument 1
|
|
|
|
# define optional_argument 2
|
1998-09-23 15:28:54 +00:00
|
|
|
#endif /* need getopt */
|
|
|
|
|
|
|
|
|
|
|
|
/* Get definitions and prototypes for functions to process the
|
|
|
|
arguments in ARGV (ARGC of them, minus the program name) for
|
|
|
|
options given in OPTS.
|
|
|
|
|
|
|
|
Return the option character from OPTS just read. Return -1 when
|
|
|
|
there are no more options. For unrecognized options, or options
|
2017-03-31 11:39:55 +00:00
|
|
|
missing arguments, 'optopt' is set to the option letter, and '?' is
|
1998-09-23 15:28:54 +00:00
|
|
|
returned.
|
1998-09-11 12:14:37 +00:00
|
|
|
|
1998-09-23 15:28:54 +00:00
|
|
|
The OPTS string is a list of characters which are recognized option
|
|
|
|
letters, optionally followed by colons, specifying that that letter
|
2017-03-31 11:39:55 +00:00
|
|
|
takes an argument, to be placed in 'optarg'.
|
1998-09-23 15:28:54 +00:00
|
|
|
|
|
|
|
If a letter in OPTS is followed by two colons, its argument is
|
2017-03-31 11:39:55 +00:00
|
|
|
optional. This behavior is specific to the GNU 'getopt'.
|
1998-09-23 15:28:54 +00:00
|
|
|
|
2017-03-31 11:39:55 +00:00
|
|
|
The argument '--' causes premature termination of argument
|
|
|
|
scanning, explicitly telling 'getopt' that there are no more
|
1998-09-23 15:28:54 +00:00
|
|
|
options.
|
|
|
|
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
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.
|
|
|
|
|
|
|
|
For standards compliance, the 'argv' argument has the type
|
|
|
|
char *const *, but this is inaccurate; if argument permutation is
|
|
|
|
enabled, the argv array (not the strings it points to) must be
|
|
|
|
writable. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
Update.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* grp/Makefile (CFLAGS-getgrgid_r.c, CFLAGS-getgrnam_r.c,
CFLAGS-fgetgrent.c, CFLAGS-fgetgrent_r.c, CFLAGS-putgrent.c,
CFLAGS-initgroups.c, CFLAGS-getgrgid.c): Add -fexceptions.
* inet/Makefile (CFLAGS-either_ntoh.c, CFLAGS-either_hton.c,
CFLAGS-getnetgrent.c, CFLAGS-getnetgrent_r.c): Likewise.
* io/Makefile (CFLAGS-posix_fallocate.c, CFLAGS-posix_fallocate64.c):
Likewise.
* misc/Makefile (CFLAGS-err.c): Likewise.
* posix/Makefile (CFLAGS-getaddrinfo.c, CFLAGS-spawn.c,
CFLAGS-spawnp.c, CFLAGS-spawni.c, CFLAGS-pause.c, CFLAGS-glob.c,
CFLAGS-glob64.c): Likewise.
* pwd/Makefile (CFLAGS-getpw.c): Likewise.
* shadow/Makefile (CFLAGS-fgetspent.c, CFLAGS-fgetspent_r.c,
CFLAGS-putspent.c, CFLAGS-getspnam.c, CFLAGS-getspnam_r.c): Likewise.
* stdio-common/Makefile (CFLAGS-cuserid.c): Likewise.
* sunrpc/Makefile (CFLAGS-openchild.c): Likewise.
* stdlib/Makefile (CFLAGS-mkstemp.c): Remove definition.
* libio/stdio.h: Remove __THROW from cuserid prototype.
* locale/loadarchive.c: Use only non-cancelable interfaces.
* resolv/herror.c (herror): Likewise.
* malloc/hooks.c: Before using IO stream mark stream so it uses
only non-cancelable interfaces.
* malloc/malloc.c: Likewise.
* posix/getopt.c: Likewise.
2003-09-11 Jakub Jelinek <jakub@redhat.com>
* Makerules (LDFLAGS-c.so): Remove -u __register_frame.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* stdio-common/stdio_ext.h: Mark most functions with __THROW.
* misc/err.h: Remove __THROW from all prototypes.
* posix/getopt.h (__THROW): Define if not already defined. Add
__THROW to the getopt functions.
2003-09-11 Ulrich Drepper <drepper@redhat.com>
* io/Makefile (CFLAGS-lockf.c): Add -fexceptions.
(CFLAGS-fts.c): Likewise.
* io/fcntl.h: Remove __THROW from lockf prototypes.
* io/fts.h: Remove most __THROW.
2003-09-12 22:37:19 +00:00
|
|
|
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
__THROW __nonnull ((2, 3));
|
2009-02-26 01:22:06 +00:00
|
|
|
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
#if defined __need_getopt && defined __USE_POSIX2 \
|
|
|
|
&& !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
|
2009-02-26 01:22:06 +00:00
|
|
|
/* 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. */
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
# ifdef __REDIRECT
|
2010-06-14 15:18:26 +00:00
|
|
|
extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
|
|
|
|
const char *__shortopts),
|
|
|
|
__posix_getopt);
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
# else
|
2009-02-26 01:22:06 +00:00
|
|
|
extern int __posix_getopt (int ___argc, char *const *___argv,
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
const char *__shortopts)
|
|
|
|
__THROW __nonnull ((2, 3));
|
|
|
|
# define getopt __posix_getopt
|
2009-02-26 01:22:06 +00:00
|
|
|
# endif
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
#endif
|
1998-09-11 12:14:37 +00:00
|
|
|
|
Update.
2004-03-08 Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib. We now assume C89 or better.
* posix/getopt1.c (const): Remove.
* posix/getopt.c (const): Likewise.
* posix/getopt1.c (getopt_long, _getopt_long_r, getopt_long_only,
_getopt_long_only_r, main): Use prototypes, not old-style definitions.
* posix/getopt.c (exchange, _getopt_initialize, _getopt_internal_r,
_getopt_internal, getopt, main): Likewise.
* posix/getopt.h (getopt, getopt_long, getopt_long_only): Likewise.
* posix/getopt.c [!defined VMS || !HAVE_STRING_H]:
Include <string.h> regardless. No need for <strings.h>.
[!defined _LIBC]: Include "gettext.h" rather than rolling it ourselves.
(_): Define to gettext always.
(my_index): Remove: all uses changed to strchr.
(strlen): Remove declaration.
* posix/getopt.h (struct option.name): Always const char *.
2004-03-08 Marcus Brinkmann <marcus@gnu.org>
* posix/getopt.h (_getopt_internal): Move to ...
* posix/getopt_int.h: ... here. New file.
* include/getopt_int.h: New file.
* include/getopt.h: Remove libc_hidden_proto for getopt_long
and getopt_long_only.
* posix/getopt1.c: Include "getopt_int.h". Remove
libc_hidden_def for getopt_long and getopt_long_only.
(_getopt_long_r, _getopt_long_only_r): New functions.
* posix/getopt.c: Include "getopt_int.h".
(__getopt_initialized): Variable removed.
(nextchar, ordering, posixly_correct, first_nonopt, last_nonopt):
Static variables removed.
(nonoption_flags_max_len, nonoption_flags_len) [_LIBC &&
USE_NONOPTION_FLAGS]: Static variables removed.
(getopt_data): New static variable.
(SWAP_FLAGS): Use d->__nonoption_flags_len instead
nonoption_flags_len.
(exchange): Add new argument D of type struct getopt_data *.
Replace optind with d->optind, optarg with d->optarg, opterr with
d->opterr, optopt with d->optopt, nextchar with d->__nextchar,
first_nonopt with d->__first_nonopt, last_nonopt with
d->__last_nonopt, d->ordering with d->__ordering,
d->posixly_correct with d->__posixly_correct (which is now an
int instead a string, so fix users), nonoption_flags_len
with d->__nonoption_flags_len, nonoption_flags_max_len with
d->__nonoption_flags_max_len.
(_getopt_initialize): Likewise.
(_getopt_internal): Rename to ...
(_getopt_internal_r): ... this. Also add new argument D of type
struct getopt_data * and use of members of D rather than global or
static variables as described for exchange() above. Add new argument
to invocations of _getopt_initialize and exchange.
(_getopt_internal): Reimplement in terms of _getopt_internal_r.
* argp/argp-parse.c: Include <getopt_int.h>.
[_LIBC]: Do not include <bits/libc-lock.h>.
[!_LIBC && HAVE_CTHREADS_H]: Do not include <cthreads.h>.
[!_LIBC] (_argp_hang): Make static.
(getopt_lock, LOCK_GETOPT, UNLOCK_GETOPT): Remove.
(_argp_unlock_xxx): Remove.
(parser_init): Do not use LOCK_GETOPT.
(parser_finalize): Do not use UNLOCK_GETOPT.
(struct parser): New member OPT_DATA.
(parser_init): Initialize parser->opt_data. Use
parser->opt_data.opterr instead of opterr.
(parser_parse_opt): Use parser->opt_data.optarg instead optarg.
(parser_parse_next): Likewise. Use parser->opt_data.optind
instead optind. Use parser->opt_data.optopt instead of optopt.
Call _getopt_long_only_r and _getopt_long_r instead of
getopt_long_only and getopt_long, and pass the extra argument.
2004-03-09 10:36:53 +00:00
|
|
|
#ifndef __need_getopt
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
|
|
|
|
/* The type of the 'argv' argument to getopt_long and getopt_long_only
|
|
|
|
is properly 'char **', since both functions may write to the array
|
|
|
|
(in order to move all the options to the beginning). However, for
|
|
|
|
compatibility with old versions of LSB, glibc has to use 'char *const *'
|
|
|
|
instead. */
|
|
|
|
#ifndef __getopt_argv_const
|
|
|
|
# define __getopt_argv_const const
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
|
2001-08-22 22:24:10 +00:00
|
|
|
const char *__shortopts,
|
Update.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* grp/Makefile (CFLAGS-getgrgid_r.c, CFLAGS-getgrnam_r.c,
CFLAGS-fgetgrent.c, CFLAGS-fgetgrent_r.c, CFLAGS-putgrent.c,
CFLAGS-initgroups.c, CFLAGS-getgrgid.c): Add -fexceptions.
* inet/Makefile (CFLAGS-either_ntoh.c, CFLAGS-either_hton.c,
CFLAGS-getnetgrent.c, CFLAGS-getnetgrent_r.c): Likewise.
* io/Makefile (CFLAGS-posix_fallocate.c, CFLAGS-posix_fallocate64.c):
Likewise.
* misc/Makefile (CFLAGS-err.c): Likewise.
* posix/Makefile (CFLAGS-getaddrinfo.c, CFLAGS-spawn.c,
CFLAGS-spawnp.c, CFLAGS-spawni.c, CFLAGS-pause.c, CFLAGS-glob.c,
CFLAGS-glob64.c): Likewise.
* pwd/Makefile (CFLAGS-getpw.c): Likewise.
* shadow/Makefile (CFLAGS-fgetspent.c, CFLAGS-fgetspent_r.c,
CFLAGS-putspent.c, CFLAGS-getspnam.c, CFLAGS-getspnam_r.c): Likewise.
* stdio-common/Makefile (CFLAGS-cuserid.c): Likewise.
* sunrpc/Makefile (CFLAGS-openchild.c): Likewise.
* stdlib/Makefile (CFLAGS-mkstemp.c): Remove definition.
* libio/stdio.h: Remove __THROW from cuserid prototype.
* locale/loadarchive.c: Use only non-cancelable interfaces.
* resolv/herror.c (herror): Likewise.
* malloc/hooks.c: Before using IO stream mark stream so it uses
only non-cancelable interfaces.
* malloc/malloc.c: Likewise.
* posix/getopt.c: Likewise.
2003-09-11 Jakub Jelinek <jakub@redhat.com>
* Makerules (LDFLAGS-c.so): Remove -u __register_frame.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* stdio-common/stdio_ext.h: Mark most functions with __THROW.
* misc/err.h: Remove __THROW from all prototypes.
* posix/getopt.h (__THROW): Define if not already defined. Add
__THROW to the getopt functions.
2003-09-11 Ulrich Drepper <drepper@redhat.com>
* io/Makefile (CFLAGS-lockf.c): Add -fexceptions.
(CFLAGS-fts.c): Likewise.
* io/fcntl.h: Remove __THROW from lockf prototypes.
* io/fts.h: Remove most __THROW.
2003-09-12 22:37:19 +00:00
|
|
|
const struct option *__longopts, int *__longind)
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
__THROW __nonnull ((2, 3));
|
|
|
|
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
1998-11-08 12:02:25 +00:00
|
|
|
const char *__shortopts,
|
Update.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* grp/Makefile (CFLAGS-getgrgid_r.c, CFLAGS-getgrnam_r.c,
CFLAGS-fgetgrent.c, CFLAGS-fgetgrent_r.c, CFLAGS-putgrent.c,
CFLAGS-initgroups.c, CFLAGS-getgrgid.c): Add -fexceptions.
* inet/Makefile (CFLAGS-either_ntoh.c, CFLAGS-either_hton.c,
CFLAGS-getnetgrent.c, CFLAGS-getnetgrent_r.c): Likewise.
* io/Makefile (CFLAGS-posix_fallocate.c, CFLAGS-posix_fallocate64.c):
Likewise.
* misc/Makefile (CFLAGS-err.c): Likewise.
* posix/Makefile (CFLAGS-getaddrinfo.c, CFLAGS-spawn.c,
CFLAGS-spawnp.c, CFLAGS-spawni.c, CFLAGS-pause.c, CFLAGS-glob.c,
CFLAGS-glob64.c): Likewise.
* pwd/Makefile (CFLAGS-getpw.c): Likewise.
* shadow/Makefile (CFLAGS-fgetspent.c, CFLAGS-fgetspent_r.c,
CFLAGS-putspent.c, CFLAGS-getspnam.c, CFLAGS-getspnam_r.c): Likewise.
* stdio-common/Makefile (CFLAGS-cuserid.c): Likewise.
* sunrpc/Makefile (CFLAGS-openchild.c): Likewise.
* stdlib/Makefile (CFLAGS-mkstemp.c): Remove definition.
* libio/stdio.h: Remove __THROW from cuserid prototype.
* locale/loadarchive.c: Use only non-cancelable interfaces.
* resolv/herror.c (herror): Likewise.
* malloc/hooks.c: Before using IO stream mark stream so it uses
only non-cancelable interfaces.
* malloc/malloc.c: Likewise.
* posix/getopt.c: Likewise.
2003-09-11 Jakub Jelinek <jakub@redhat.com>
* Makerules (LDFLAGS-c.so): Remove -u __register_frame.
2003-09-12 Ulrich Drepper <drepper@redhat.com>
* stdio-common/stdio_ext.h: Mark most functions with __THROW.
* misc/err.h: Remove __THROW from all prototypes.
* posix/getopt.h (__THROW): Define if not already defined. Add
__THROW to the getopt functions.
2003-09-11 Ulrich Drepper <drepper@redhat.com>
* io/Makefile (CFLAGS-lockf.c): Add -fexceptions.
(CFLAGS-fts.c): Likewise.
* io/fcntl.h: Remove __THROW from lockf prototypes.
* io/fts.h: Remove most __THROW.
2003-09-12 22:37:19 +00:00
|
|
|
const struct option *__longopts, int *__longind)
|
getopt: merge from gnulib: function prototype adjustments
For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.
Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.
At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.
* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib. Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib. Prototype
unconditionally. Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib. Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
2017-04-01 16:11:33 +00:00
|
|
|
__THROW __nonnull ((2, 3));
|
1995-02-18 01:27:10 +00:00
|
|
|
|
Update.
2004-03-08 Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib. We now assume C89 or better.
* posix/getopt1.c (const): Remove.
* posix/getopt.c (const): Likewise.
* posix/getopt1.c (getopt_long, _getopt_long_r, getopt_long_only,
_getopt_long_only_r, main): Use prototypes, not old-style definitions.
* posix/getopt.c (exchange, _getopt_initialize, _getopt_internal_r,
_getopt_internal, getopt, main): Likewise.
* posix/getopt.h (getopt, getopt_long, getopt_long_only): Likewise.
* posix/getopt.c [!defined VMS || !HAVE_STRING_H]:
Include <string.h> regardless. No need for <strings.h>.
[!defined _LIBC]: Include "gettext.h" rather than rolling it ourselves.
(_): Define to gettext always.
(my_index): Remove: all uses changed to strchr.
(strlen): Remove declaration.
* posix/getopt.h (struct option.name): Always const char *.
2004-03-08 Marcus Brinkmann <marcus@gnu.org>
* posix/getopt.h (_getopt_internal): Move to ...
* posix/getopt_int.h: ... here. New file.
* include/getopt_int.h: New file.
* include/getopt.h: Remove libc_hidden_proto for getopt_long
and getopt_long_only.
* posix/getopt1.c: Include "getopt_int.h". Remove
libc_hidden_def for getopt_long and getopt_long_only.
(_getopt_long_r, _getopt_long_only_r): New functions.
* posix/getopt.c: Include "getopt_int.h".
(__getopt_initialized): Variable removed.
(nextchar, ordering, posixly_correct, first_nonopt, last_nonopt):
Static variables removed.
(nonoption_flags_max_len, nonoption_flags_len) [_LIBC &&
USE_NONOPTION_FLAGS]: Static variables removed.
(getopt_data): New static variable.
(SWAP_FLAGS): Use d->__nonoption_flags_len instead
nonoption_flags_len.
(exchange): Add new argument D of type struct getopt_data *.
Replace optind with d->optind, optarg with d->optarg, opterr with
d->opterr, optopt with d->optopt, nextchar with d->__nextchar,
first_nonopt with d->__first_nonopt, last_nonopt with
d->__last_nonopt, d->ordering with d->__ordering,
d->posixly_correct with d->__posixly_correct (which is now an
int instead a string, so fix users), nonoption_flags_len
with d->__nonoption_flags_len, nonoption_flags_max_len with
d->__nonoption_flags_max_len.
(_getopt_initialize): Likewise.
(_getopt_internal): Rename to ...
(_getopt_internal_r): ... this. Also add new argument D of type
struct getopt_data * and use of members of D rather than global or
static variables as described for exchange() above. Add new argument
to invocations of _getopt_initialize and exchange.
(_getopt_internal): Reimplement in terms of _getopt_internal_r.
* argp/argp-parse.c: Include <getopt_int.h>.
[_LIBC]: Do not include <bits/libc-lock.h>.
[!_LIBC && HAVE_CTHREADS_H]: Do not include <cthreads.h>.
[!_LIBC] (_argp_hang): Make static.
(getopt_lock, LOCK_GETOPT, UNLOCK_GETOPT): Remove.
(_argp_unlock_xxx): Remove.
(parser_init): Do not use LOCK_GETOPT.
(parser_finalize): Do not use UNLOCK_GETOPT.
(struct parser): New member OPT_DATA.
(parser_init): Initialize parser->opt_data. Use
parser->opt_data.opterr instead of opterr.
(parser_parse_opt): Use parser->opt_data.optarg instead optarg.
(parser_parse_next): Likewise. Use parser->opt_data.optind
instead optind. Use parser->opt_data.optopt instead of optopt.
Call _getopt_long_only_r and _getopt_long_r instead of
getopt_long_only and getopt_long, and pass the extra argument.
2004-03-09 10:36:53 +00:00
|
|
|
#endif
|
1995-02-18 01:27:10 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-09-24 13:51:51 +00:00
|
|
|
/* Make sure we later can get all the definitions and declarations. */
|
1998-09-23 15:28:54 +00:00
|
|
|
#undef __need_getopt
|
|
|
|
|
1997-06-21 02:59:26 +00:00
|
|
|
#endif /* getopt.h */
|