diff options
Diffstat (limited to 'posix')
-rw-r--r-- | posix/getopt.h | 40 | ||||
-rw-r--r-- | posix/unistd.h | 36 |
2 files changed, 40 insertions, 36 deletions
diff --git a/posix/getopt.h b/posix/getopt.h index c9414373a5..c8950ee4a1 100644 --- a/posix/getopt.h +++ b/posix/getopt.h @@ -18,7 +18,10 @@ Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H -#define _GETOPT_H 1 + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif #ifdef __cplusplus extern "C" { @@ -55,7 +58,7 @@ extern int opterr; extern int optopt; -#ifdef _GNU_SOURCE +#ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is @@ -96,8 +99,32 @@ struct option # define no_argument 0 # define required_argument 1 # define optional_argument 2 -#endif /* GNU source */ +#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 + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ #if defined __STDC__ && __STDC__ # ifdef __GNU_LIBRARY__ @@ -109,7 +136,7 @@ extern int getopt (int argc, char *const *argv, const char *shortopts); extern int getopt (); # endif /* __GNU_LIBRARY__ */ -# ifdef _GNU_SOURCE +# ifdef __need_getopt extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, @@ -124,7 +151,7 @@ extern int _getopt_internal (int argc, char *const *argv, # endif #else /* not __STDC__ */ extern int getopt (); -# ifdef _GNU_SOURCE +# ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); @@ -136,4 +163,7 @@ extern int _getopt_internal (); } #endif +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + #endif /* getopt.h */ diff --git a/posix/unistd.h b/posix/unistd.h index aa7deffd57..3ea24818d3 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -718,37 +718,11 @@ extern int setlogin __P ((__const char *__name)); #ifdef __USE_POSIX2 -/* Process the arguments in ARGV (ARGC of them, minus - the program name) for options given in OPTS. - - If `opterr' is zero, no messages are generated - for invalid options; it defaults to 1. - `optind' is the current index into ARGV. - `optarg' is the argument corresponding to the current option. - Return the option character from OPTS just read. - Return -1 when there are no more options. - For unrecognized options, or options missing arguments, - `optopt' is set to the option letter, and '?' is returned. - - The OPTS string is a list of characters which are recognized option - letters, optionally followed by colons, specifying that that letter - takes an argument, to be placed in `optarg'. - - If a letter in OPTS is followed by two colons, its argument is optional. - This behavior is specific to the GNU `getopt'. - - The argument `--' causes premature termination of argument scanning, - explicitly telling `getopt' that there are no more options. - - If OPTS begins with `--', then non-option arguments - are treated as arguments to the option '\0'. - This behavior is specific to the GNU `getopt'. */ -extern int getopt __P ((int __argc, char *__const * __argv, - __const char *__opts)); -extern int opterr; -extern int optind; -extern int optopt; -extern char *optarg; +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. */ +# define __need_getopt +# include <getopt.h> #endif |