mirror of git://sourceware.org/git/glibc.git
getopt: merge from gnulib: don't use `...' quotes
I'm not sure whether this is official GNU style now, but `...' quotes haven't looked properly balanced in most people's terminal fonts since 2001ish? and gnulib has chosen to switch over to '...' quotes. I'm merging this separately from the other changes in gnulib because it's very mechanical. * posix/getopt.c, posix/getopt.h, posix/getopt1.c, posix/getopt_int.h: Use '...' instead of `...' for quotation marks inside comments and strings.
This commit is contained in:
parent
bf079e19f5
commit
7784135eb0
|
@ -1,5 +1,9 @@
|
||||||
2017-04-07 Zack Weinberg <zackw@panix.com>
|
2017-04-07 Zack Weinberg <zackw@panix.com>
|
||||||
|
|
||||||
|
* posix/getopt.c, posix/getopt.h, posix/getopt1.c, posix/getopt_int.h:
|
||||||
|
Use '...' instead of `...' for quotation marks inside
|
||||||
|
comments and strings.
|
||||||
|
|
||||||
* config.h.in (USE_NONOPTION_FLAGS): Remove.
|
* config.h.in (USE_NONOPTION_FLAGS): Remove.
|
||||||
* csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
|
* csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
|
||||||
* sysdeps/mach/hurd/i386/init-first.c: Likewise.
|
* sysdeps/mach/hurd/i386/init-first.c: Likewise.
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
Library, but also included in many other GNU distributions. Compiling
|
Library, but also included in many other GNU distributions. Compiling
|
||||||
and linking in this code is a waste when using the GNU C library
|
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
|
(especially if it is a shared library). Rather than having every GNU
|
||||||
program understand `configure --with-gnu-libc' and omit the object files,
|
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. */
|
it is simpler to just do this in the source for each such file. */
|
||||||
|
|
||||||
#define GETOPT_INTERFACE_VERSION 2
|
#define GETOPT_INTERFACE_VERSION 2
|
||||||
|
@ -80,11 +80,11 @@
|
||||||
# define attribute_hidden
|
# define attribute_hidden
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
/* This version of 'getopt' appears to the caller like standard Unix 'getopt'
|
||||||
but it behaves differently for the user, since it allows the user
|
but it behaves differently for the user, since it allows the user
|
||||||
to intersperse the options with the other arguments.
|
to intersperse the options with the other arguments.
|
||||||
|
|
||||||
As `getopt' works, it permutes the elements of ARGV so that,
|
As 'getopt' works, it permutes the elements of ARGV so that,
|
||||||
when it is done, all the options precede everything else. Thus
|
when it is done, all the options precede everything else. Thus
|
||||||
all application programs are extended to handle flexible argument order.
|
all application programs are extended to handle flexible argument order.
|
||||||
|
|
||||||
|
@ -97,24 +97,24 @@
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
#include "getopt_int.h"
|
#include "getopt_int.h"
|
||||||
|
|
||||||
/* For communication from `getopt' to the caller.
|
/* For communication from 'getopt' to the caller.
|
||||||
When `getopt' finds an option that takes an argument,
|
When 'getopt' finds an option that takes an argument,
|
||||||
the argument value is returned here.
|
the argument value is returned here.
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
Also, when 'ordering' is RETURN_IN_ORDER,
|
||||||
each non-option ARGV-element is returned here. */
|
each non-option ARGV-element is returned here. */
|
||||||
|
|
||||||
char *optarg;
|
char *optarg;
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
/* Index in ARGV of the next element to be scanned.
|
||||||
This is used for communication to and from the caller
|
This is used for communication to and from the caller
|
||||||
and for communication between successive calls to `getopt'.
|
and for communication between successive calls to 'getopt'.
|
||||||
|
|
||||||
On entry to `getopt', zero means this is the first call; initialize.
|
On entry to 'getopt', zero means this is the first call; initialize.
|
||||||
|
|
||||||
When `getopt' returns -1, this is the index of the first of the
|
When 'getopt' returns -1, this is the index of the first of the
|
||||||
non-option elements that the caller should itself scan.
|
non-option elements that the caller should itself scan.
|
||||||
|
|
||||||
Otherwise, `optind' communicates from one call to the next
|
Otherwise, 'optind' communicates from one call to the next
|
||||||
how much of ARGV has been scanned so far. */
|
how much of ARGV has been scanned so far. */
|
||||||
|
|
||||||
/* 1003.2 says this must be 1 before any call. */
|
/* 1003.2 says this must be 1 before any call. */
|
||||||
|
@ -153,7 +153,7 @@ extern char *getenv ();
|
||||||
The other is elements [last_nonopt,optind), which contains all
|
The other is elements [last_nonopt,optind), which contains all
|
||||||
the options processed since those non-options were skipped.
|
the options processed since those non-options were skipped.
|
||||||
|
|
||||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
'first_nonopt' and 'last_nonopt' are relocated so that they describe
|
||||||
the new indices of the non-options in ARGV after they are moved. */
|
the new indices of the non-options in ARGV after they are moved. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -252,48 +252,48 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring,
|
||||||
|
|
||||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
||||||
then it is an option element. The characters of this element
|
then it is an option element. The characters of this element
|
||||||
(aside from the initial '-') are option characters. If `getopt'
|
(aside from the initial '-') are option characters. If 'getopt'
|
||||||
is called repeatedly, it returns successively each of the option characters
|
is called repeatedly, it returns successively each of the option characters
|
||||||
from each of the option elements.
|
from each of the option elements.
|
||||||
|
|
||||||
If `getopt' finds another option character, it returns that character,
|
If 'getopt' finds another option character, it returns that character,
|
||||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
updating 'optind' and 'nextchar' so that the next call to 'getopt' can
|
||||||
resume the scan with the following option character or ARGV-element.
|
resume the scan with the following option character or ARGV-element.
|
||||||
|
|
||||||
If there are no more option characters, `getopt' returns -1.
|
If there are no more option characters, 'getopt' returns -1.
|
||||||
Then `optind' is the index in ARGV of the first ARGV-element
|
Then 'optind' is the index in ARGV of the first ARGV-element
|
||||||
that is not an option. (The ARGV-elements have been permuted
|
that is not an option. (The ARGV-elements have been permuted
|
||||||
so that those that are not options now come last.)
|
so that those that are not options now come last.)
|
||||||
|
|
||||||
OPTSTRING is a string containing the legitimate option characters.
|
OPTSTRING is a string containing the legitimate option characters.
|
||||||
If an option character is seen that is not listed in OPTSTRING,
|
If an option character is seen that is not listed in OPTSTRING,
|
||||||
return '?' after printing an error message. If you set `opterr' to
|
return '?' after printing an error message. If you set 'opterr' to
|
||||||
zero, the error message is suppressed but we still return '?'.
|
zero, the error message is suppressed but we still return '?'.
|
||||||
|
|
||||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
||||||
so the following text in the same ARGV-element, or the text of the following
|
so the following text in the same ARGV-element, or the text of the following
|
||||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
ARGV-element, is returned in 'optarg'. Two colons mean an option that
|
||||||
wants an optional arg; if there is text in the current ARGV-element,
|
wants an optional arg; if there is text in the current ARGV-element,
|
||||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
it is returned in 'optarg', otherwise 'optarg' is set to zero.
|
||||||
|
|
||||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
If OPTSTRING starts with '-' or '+', it requests different methods of
|
||||||
handling the non-option ARGV-elements.
|
handling the non-option ARGV-elements.
|
||||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
||||||
|
|
||||||
Long-named options begin with `--' instead of `-'.
|
Long-named options begin with '--' instead of '-'.
|
||||||
Their names may be abbreviated as long as the abbreviation is unique
|
Their names may be abbreviated as long as the abbreviation is unique
|
||||||
or is an exact match for some defined option. If they have an
|
or is an exact match for some defined option. If they have an
|
||||||
argument, it follows the option name in the same ARGV-element, separated
|
argument, it follows the option name in the same ARGV-element, separated
|
||||||
from the option name by a `=', or else the in next ARGV-element.
|
from the option name by a '=', or else the in next ARGV-element.
|
||||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
When 'getopt' finds a long-named option, it returns 0 if that option's
|
||||||
`flag' field is nonzero, the value of the option's `val' field
|
'flag' field is nonzero, the value of the option's 'val' field
|
||||||
if the `flag' field is zero.
|
if the 'flag' field is zero.
|
||||||
|
|
||||||
The elements of ARGV aren't really const, because we permute them.
|
The elements of ARGV aren't really const, because we permute them.
|
||||||
But we pretend they're const in the prototype to be compatible
|
But we pretend they're const in the prototype to be compatible
|
||||||
with other systems.
|
with other systems.
|
||||||
|
|
||||||
LONGOPTS is a vector of `struct option' terminated by an
|
LONGOPTS is a vector of 'struct option' terminated by an
|
||||||
element containing a name which is zero.
|
element containing a name which is zero.
|
||||||
|
|
||||||
LONGIND returns the index in LONGOPT of the long-named option found.
|
LONGIND returns the index in LONGOPT of the long-named option found.
|
||||||
|
@ -361,7 +361,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
|
||||||
d->__last_nonopt = d->optind;
|
d->__last_nonopt = d->optind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The special ARGV-element `--' means premature end of options.
|
/* The special ARGV-element '--' means premature end of options.
|
||||||
Skip it like a null option,
|
Skip it like a null option,
|
||||||
then exchange with previous non-options as if it were an option,
|
then exchange with previous non-options as if it were an option,
|
||||||
then skip everything else like a non-option. */
|
then skip everything else like a non-option. */
|
||||||
|
@ -733,7 +733,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
|
||||||
char c = *d->__nextchar++;
|
char c = *d->__nextchar++;
|
||||||
char *temp = strchr (optstring, c);
|
char *temp = strchr (optstring, c);
|
||||||
|
|
||||||
/* Increment `optind' when we start to process its last character. */
|
/* Increment 'optind' when we start to process its last character. */
|
||||||
if (*d->__nextchar == '\0')
|
if (*d->__nextchar == '\0')
|
||||||
++d->optind;
|
++d->optind;
|
||||||
|
|
||||||
|
@ -832,7 +832,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* We already incremented `d->optind' once;
|
/* We already incremented 'd->optind' once;
|
||||||
increment it again when taking next ARGV-elt as argument. */
|
increment it again when taking next ARGV-elt as argument. */
|
||||||
d->optarg = argv[d->optind++];
|
d->optarg = argv[d->optind++];
|
||||||
|
|
||||||
|
@ -1059,7 +1059,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring,
|
||||||
c = '?';
|
c = '?';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* We already incremented `optind' once;
|
/* We already incremented 'optind' once;
|
||||||
increment it again when taking next ARGV-elt as argument. */
|
increment it again when taking next ARGV-elt as argument. */
|
||||||
d->optarg = argv[d->optind++];
|
d->optarg = argv[d->optind++];
|
||||||
d->__nextchar = NULL;
|
d->__nextchar = NULL;
|
||||||
|
@ -1115,7 +1115,7 @@ __posix_getopt (int argc, char *const *argv, const char *optstring)
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
|
|
||||||
/* Compile with -DTEST to make an executable for use in testing
|
/* Compile with -DTEST to make an executable for use in testing
|
||||||
the above definition of `getopt'. */
|
the above definition of 'getopt'. */
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
|
|
|
@ -48,29 +48,29 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For communication from `getopt' to the caller.
|
/* For communication from 'getopt' to the caller.
|
||||||
When `getopt' finds an option that takes an argument,
|
When 'getopt' finds an option that takes an argument,
|
||||||
the argument value is returned here.
|
the argument value is returned here.
|
||||||
Also, when `ordering' is RETURN_IN_ORDER,
|
Also, when 'ordering' is RETURN_IN_ORDER,
|
||||||
each non-option ARGV-element is returned here. */
|
each non-option ARGV-element is returned here. */
|
||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
|
|
||||||
/* Index in ARGV of the next element to be scanned.
|
/* Index in ARGV of the next element to be scanned.
|
||||||
This is used for communication to and from the caller
|
This is used for communication to and from the caller
|
||||||
and for communication between successive calls to `getopt'.
|
and for communication between successive calls to 'getopt'.
|
||||||
|
|
||||||
On entry to `getopt', zero means this is the first call; initialize.
|
On entry to 'getopt', zero means this is the first call; initialize.
|
||||||
|
|
||||||
When `getopt' returns -1, this is the index of the first of the
|
When 'getopt' returns -1, this is the index of the first of the
|
||||||
non-option elements that the caller should itself scan.
|
non-option elements that the caller should itself scan.
|
||||||
|
|
||||||
Otherwise, `optind' communicates from one call to the next
|
Otherwise, 'optind' communicates from one call to the next
|
||||||
how much of ARGV has been scanned so far. */
|
how much of ARGV has been scanned so far. */
|
||||||
|
|
||||||
extern int optind;
|
extern int optind;
|
||||||
|
|
||||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
/* Callers store zero here to inhibit the error message 'getopt' prints
|
||||||
for unrecognized options. */
|
for unrecognized options. */
|
||||||
|
|
||||||
extern int opterr;
|
extern int opterr;
|
||||||
|
@ -82,24 +82,24 @@ extern int optopt;
|
||||||
#ifndef __need_getopt
|
#ifndef __need_getopt
|
||||||
/* Describe the long-named options requested by the application.
|
/* Describe the long-named options requested by the application.
|
||||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
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
|
of 'struct option' terminated by an element containing a name which is
|
||||||
zero.
|
zero.
|
||||||
|
|
||||||
The field `has_arg' is:
|
The field 'has_arg' is:
|
||||||
no_argument (or 0) if the option does not take an argument,
|
no_argument (or 0) if the option does not take an argument,
|
||||||
required_argument (or 1) if the option requires 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
|
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
|
to the value given in the field 'val' when the option is found, but
|
||||||
left unchanged if the option is not found.
|
left unchanged if the option is not found.
|
||||||
|
|
||||||
To have a long-named option do something other than set an `int' to
|
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
|
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
|
option's 'flag' field to zero and its 'val' field to a nonzero
|
||||||
value (the equivalent single-letter option character, if there is
|
value (the equivalent single-letter option character, if there is
|
||||||
one). For long options that have a zero `flag' field, `getopt'
|
one). For long options that have a zero 'flag' field, 'getopt'
|
||||||
returns the contents of the `val' field. */
|
returns the contents of the 'val' field. */
|
||||||
|
|
||||||
struct option
|
struct option
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ struct option
|
||||||
int val;
|
int val;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
/* Names for the values of the 'has_arg' field of 'struct option'. */
|
||||||
|
|
||||||
# define no_argument 0
|
# define no_argument 0
|
||||||
# define required_argument 1
|
# define required_argument 1
|
||||||
|
@ -125,23 +125,23 @@ struct option
|
||||||
|
|
||||||
Return the option character from OPTS just read. Return -1 when
|
Return the option character from OPTS just read. Return -1 when
|
||||||
there are no more options. For unrecognized options, or options
|
there are no more options. For unrecognized options, or options
|
||||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
missing arguments, 'optopt' is set to the option letter, and '?' is
|
||||||
returned.
|
returned.
|
||||||
|
|
||||||
The OPTS string is a list of characters which are recognized option
|
The OPTS string is a list of characters which are recognized option
|
||||||
letters, optionally followed by colons, specifying that that letter
|
letters, optionally followed by colons, specifying that that letter
|
||||||
takes an argument, to be placed in `optarg'.
|
takes an argument, to be placed in 'optarg'.
|
||||||
|
|
||||||
If a letter in OPTS is followed by two colons, its argument is
|
If a letter in OPTS is followed by two colons, its argument is
|
||||||
optional. This behavior is specific to the GNU `getopt'.
|
optional. This behavior is specific to the GNU 'getopt'.
|
||||||
|
|
||||||
The argument `--' causes premature termination of argument
|
The argument '--' causes premature termination of argument
|
||||||
scanning, explicitly telling `getopt' that there are no more
|
scanning, explicitly telling 'getopt' that there are no more
|
||||||
options.
|
options.
|
||||||
|
|
||||||
If OPTS begins with `--', then non-option arguments are treated as
|
If OPTS begins with '--', then non-option arguments are treated as
|
||||||
arguments to the option '\0'. This behavior is specific to the GNU
|
arguments to the option '\0'. This behavior is specific to the GNU
|
||||||
`getopt'. */
|
'getopt'. */
|
||||||
|
|
||||||
#ifdef __GNU_LIBRARY__
|
#ifdef __GNU_LIBRARY__
|
||||||
/* Many other libraries have conflicting prototypes for getopt, with
|
/* Many other libraries have conflicting prototypes for getopt, with
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
Library, but also included in many other GNU distributions. Compiling
|
Library, but also included in many other GNU distributions. Compiling
|
||||||
and linking in this code is a waste when using the GNU C library
|
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
|
(especially if it is a shared library). Rather than having every GNU
|
||||||
program understand `configure --with-gnu-libc' and omit the object files,
|
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. */
|
it is simpler to just do this in the source for each such file. */
|
||||||
|
|
||||||
#define GETOPT_INTERFACE_VERSION 2
|
#define GETOPT_INTERFACE_VERSION 2
|
||||||
|
@ -161,11 +161,11 @@ main (int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
printf ("option c with value `%s'\n", optarg);
|
printf ("option c with value '%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
printf ("option d with value `%s'\n", optarg);
|
printf ("option d with value '%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct _getopt_data
|
||||||
stop option processing when the first non-option is seen.
|
stop option processing when the first non-option is seen.
|
||||||
This is what Unix does.
|
This is what Unix does.
|
||||||
This mode of operation is selected by either setting the environment
|
This mode of operation is selected by either setting the environment
|
||||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
variable POSIXLY_CORRECT, or using '+' as the first character
|
||||||
of the list of option characters.
|
of the list of option characters.
|
||||||
|
|
||||||
PERMUTE is the default. We permute the contents of ARGV as we
|
PERMUTE is the default. We permute the contents of ARGV as we
|
||||||
|
@ -74,12 +74,12 @@ struct _getopt_data
|
||||||
written to expect options and other ARGV-elements in any order
|
written to expect options and other ARGV-elements in any order
|
||||||
and that care about the ordering of the two. We describe each
|
and that care about the ordering of the two. We describe each
|
||||||
non-option ARGV-element as if it were the argument of an option
|
non-option ARGV-element as if it were the argument of an option
|
||||||
with character code 1. Using `-' as the first character of the
|
with character code 1. Using '-' as the first character of the
|
||||||
list of option characters selects this mode of operation.
|
list of option characters selects this mode of operation.
|
||||||
|
|
||||||
The special argument `--' forces an end of option-scanning regardless
|
The special argument '--' forces an end of option-scanning regardless
|
||||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
|
||||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
'--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -93,8 +93,8 @@ struct _getopt_data
|
||||||
/* Handle permutation of arguments. */
|
/* Handle permutation of arguments. */
|
||||||
|
|
||||||
/* Describe the part of ARGV that contains non-options that have
|
/* Describe the part of ARGV that contains non-options that have
|
||||||
been skipped. `first_nonopt' is the index in ARGV of the first
|
been skipped. 'first_nonopt' is the index in ARGV of the first
|
||||||
of them; `last_nonopt' is the index after the last of them. */
|
of them; 'last_nonopt' is the index after the last of them. */
|
||||||
|
|
||||||
int __first_nonopt;
|
int __first_nonopt;
|
||||||
int __last_nonopt;
|
int __last_nonopt;
|
||||||
|
|
Loading…
Reference in New Issue