Merge from gnulib
This merges some getopt fixes from Zack Weinberg, and affects only non-GNUish platforms. It incorporates: 2017-04-06 getopt-gnu: omit some duplicate code 2017-04-06 getopt-posix: use angle-bracket include 2017-04-06 getopt: annotate files with relationship to glibc 2017-04-06 getopt: split up getopt.in.h and eliminate __need_getopt 2017-04-06 getopt: better handling of ambiguous options 2017-04-06 getopt: refactor long-option handling 2017-04-06 getopt: tidy up _getopt_initialize a bit 2017-04-06 getopt: merge from glibc: repetition reduction 2017-04-06 getopt: clean up error reporting 2017-04-06 getopt: fix fencepost error in ambiguous-W-option handling 2017-04-06 getopt: clean up getopt.c and getopt1.c file headers 2017-04-06 getopt: harmonize comments with glibc 2017-04-06 getopt: remove USE_NONOPTION_FLAGS 2017-04-06 getopt: tabify, in preparation for merge with glibc 2017-04-06 md5, sha1, sha256, sha512: Add comments re correctness * build-aux/config.sub, doc/misc/texinfo.tex, lib/getopt.c: * lib/getopt.in.h, lib/getopt1.c, lib/getopt_int.h, lib/md5.c: * lib/md5.h, lib/sha1.c, lib/sha1.h, lib/sha256.c, lib/sha256.h: * lib/sha512.c, lib/sha512.h, lib/unistd.in.h, m4/getopt.m4: Copy from gnulib. * lib/getopt_cdefs.in.h, lib/getopt_core.h, lib/getopt_ext.h: * lib/getopt_pfx_core.h, lib/getopt_pfx_ext.h: New files, taken from gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
This commit is contained in:
parent
451a0c8b69
commit
022755953f
23 changed files with 1025 additions and 1353 deletions
6
build-aux/config.sub
vendored
6
build-aux/config.sub
vendored
|
@ -2,7 +2,7 @@
|
|||
# Configuration validation subroutine script.
|
||||
# Copyright 1992-2017 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2017-03-21'
|
||||
timestamp='2017-04-02'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
@ -263,7 +263,7 @@ case $basic_machine in
|
|||
| fido | fr30 | frv | ft32 \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| hexagon \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| i370 | i860 | i960 | ia16 | ia64 \
|
||||
| ip2k | iq2000 \
|
||||
| k1om \
|
||||
| le32 | le64 \
|
||||
|
@ -389,7 +389,7 @@ case $basic_machine in
|
|||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| hexagon-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
| i*86-* | i860-* | i960-* | ia16-* | ia64-* \
|
||||
| ip2k-* | iq2000-* \
|
||||
| k1om-* \
|
||||
| le32-* | le64-* \
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
% Load plain if necessary, i.e., if running under initex.
|
||||
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
|
||||
%
|
||||
\def\texinfoversion{2017-03-07.20}
|
||||
\def\texinfoversion{2017-03-25.14}
|
||||
%
|
||||
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
|
||||
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
|
||||
% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
|
||||
% Free Software Foundation, Inc.
|
||||
%
|
||||
% This texinfo.tex file is free software: you can redistribute it and/or
|
||||
|
@ -11312,7 +11312,6 @@
|
|||
%
|
||||
\lispnarrowing = 0.3in
|
||||
\tolerance = 700
|
||||
\hfuzz = 1pt
|
||||
\contentsrightmargin = 0pt
|
||||
\defbodyindent = .5cm
|
||||
}}
|
||||
|
@ -11330,7 +11329,6 @@
|
|||
%
|
||||
\lispnarrowing = 0.25in
|
||||
\tolerance = 700
|
||||
\hfuzz = 1pt
|
||||
\contentsrightmargin = 0pt
|
||||
\defbodyindent = .4cm
|
||||
}}
|
||||
|
@ -11356,7 +11354,6 @@
|
|||
{297mm}{210mm}%
|
||||
%
|
||||
\tolerance = 700
|
||||
\hfuzz = 1pt
|
||||
\contentsrightmargin = 0pt
|
||||
\defbodyindent = 5mm
|
||||
}}
|
||||
|
@ -11375,7 +11372,6 @@
|
|||
%
|
||||
\lispnarrowing = 0.2in
|
||||
\tolerance = 800
|
||||
\hfuzz = 1.2pt
|
||||
\contentsrightmargin = 0pt
|
||||
\defbodyindent = 2mm
|
||||
\tableindent = 12mm
|
||||
|
@ -11431,6 +11427,9 @@
|
|||
%
|
||||
\letterpaper
|
||||
|
||||
% Default value of \hfuzz, for suppressing warnings about overfull hboxes.
|
||||
\hfuzz = 1pt
|
||||
|
||||
|
||||
\message{and turning on texinfo input format.}
|
||||
|
||||
|
|
1415
lib/getopt.c
1415
lib/getopt.c
File diff suppressed because it is too large
Load diff
271
lib/getopt.in.h
271
lib/getopt.in.h
|
@ -1,20 +1,22 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library, which supplies a different version of
|
||||
this file.
|
||||
|
||||
The GNU C Library 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 3 of the License, or (at your option) any later version.
|
||||
gnulib 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 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
gnulib 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
License along with gnulib; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_GETOPT_H
|
||||
|
||||
|
@ -32,249 +34,26 @@
|
|||
# undef _GL_SYSTEM_GETOPT
|
||||
#endif
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _@GUARD_PREFIX@_GETOPT_H 1
|
||||
#endif
|
||||
#define _@GUARD_PREFIX@_GETOPT_H 1
|
||||
|
||||
/* 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 (if the system had <getopt.h>,
|
||||
we have already included it). Then systematically rename
|
||||
identifiers so that they do not collide with the system functions
|
||||
and variables. Renaming avoids problems with some compilers and
|
||||
linkers. */
|
||||
defined in getopt_core.h and getopt_ext.h. When this happens,
|
||||
include the headers that might declare getopt so that they will not
|
||||
cause confusion if included after this file (if the system had
|
||||
<getopt.h>, we have already included it). */
|
||||
#if defined __GETOPT_PREFIX
|
||||
# if !defined __need_getopt
|
||||
# if !@HAVE_GETOPT_H@
|
||||
# define __need_system_stdlib_h
|
||||
# include <stdlib.h>
|
||||
# undef __need_system_stdlib_h
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
# undef __need_getopt
|
||||
# endif
|
||||
# undef __GETOPT_CONCAT
|
||||
# undef __GETOPT_XCONCAT
|
||||
# undef __GETOPT_ID
|
||||
# undef getopt
|
||||
# undef getopt_long
|
||||
# undef getopt_long_only
|
||||
# undef optarg
|
||||
# undef opterr
|
||||
# undef optind
|
||||
# undef optopt
|
||||
# undef option
|
||||
# undef _getopt_internal
|
||||
# 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)
|
||||
# define option __GETOPT_ID (option)
|
||||
# define _getopt_internal __GETOPT_ID (getopt_internal)
|
||||
#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
|
||||
# if !@HAVE_GETOPT_H@
|
||||
# define __need_system_stdlib_h
|
||||
# include <stdlib.h>
|
||||
# undef __need_system_stdlib_h
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# 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
|
||||
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
|
||||
|
||||
#ifndef __THROW
|
||||
# ifndef __GNUC_PREREQ
|
||||
# define __GNUC_PREREQ(maj, min) (0)
|
||||
# endif
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from 'getopt' to the caller.
|
||||
When 'getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when 'ordering' is RETURN_IN_ORDER,
|
||||
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
|
||||
and for communication between successive calls to 'getopt'.
|
||||
|
||||
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
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, 'optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message 'getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#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
|
||||
zero.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
left unchanged if the option is not found.
|
||||
|
||||
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
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero 'flag' field, 'getopt'
|
||||
returns the contents of the 'val' field. */
|
||||
|
||||
# if !GNULIB_defined_struct_option
|
||||
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;
|
||||
};
|
||||
# define GNULIB_defined_struct_option 1
|
||||
# endif
|
||||
|
||||
/* Names for the values of the 'has_arg' field of 'struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#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 '\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. */
|
||||
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
|
||||
#ifndef __GETOPT_PREFIX
|
||||
# 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_NTH (getopt, (int ___argc, char *const *___argv,
|
||||
const char *__shortopts),
|
||||
__posix_getopt);
|
||||
# else
|
||||
extern int __posix_getopt (int ___argc, char *const *___argv,
|
||||
const char *__shortopts)
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
# define getopt __posix_getopt
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
#include <getopt_cdefs.h>
|
||||
#include <getopt_pfx_core.h>
|
||||
#include <getopt_pfx_ext.h>
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_GETOPT_H */
|
||||
#endif /* _@GUARD_PREFIX@_GETOPT_H */
|
||||
|
|
143
lib/getopt1.c
143
lib/getopt1.c
|
@ -1,6 +1,7 @@
|
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987-2017 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
|
@ -16,41 +17,28 @@
|
|||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <getopt.h>
|
||||
#else
|
||||
#ifndef _LIBC
|
||||
# include <config.h>
|
||||
# include "getopt.h"
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
#include "getopt_int.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 0, 0);
|
||||
opt_index, 0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
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, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
|
@ -60,26 +48,27 @@ _getopt_long_r (int argc, char **argv, const char *options,
|
|||
|
||||
int
|
||||
getopt_long_only (int argc, char *__getopt_argv_const *argv,
|
||||
const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 1, 0);
|
||||
opt_index, 1, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_only_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
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, 0);
|
||||
1, d, 0);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -93,74 +82,74 @@ main (int argc, char **argv)
|
|||
int option_index = 0;
|
||||
static const struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value '%s'\n", optarg);
|
||||
break;
|
||||
case 'c':
|
||||
printf ("option c with value '%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value '%s'\n", optarg);
|
||||
break;
|
||||
case 'd':
|
||||
printf ("option d with value '%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
|
75
lib/getopt_cdefs.in.h
Normal file
75
lib/getopt_cdefs.in.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* getopt-on-non-glibc compatibility macros.
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
||||
gnulib 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 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
gnulib 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with gnulib; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_CDEFS_H
|
||||
#define _GETOPT_CDEFS_H 1
|
||||
|
||||
/* This header should not be used directly; include getopt.h or
|
||||
unistd.h instead. It does not have a protective #error, because
|
||||
the guard macro for getopt.h in gnulib is not fixed. */
|
||||
|
||||
/* getopt_core.h and getopt_ext.h are shared with GNU libc, and expect
|
||||
a number of the internal macros supplied to GNU libc's headers by
|
||||
sys/cdefs.h. Provide fallback definitions for all of them. */
|
||||
#if @HAVE_SYS_CDEFS_H@
|
||||
# include <sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
# ifdef __cplusplus
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# else
|
||||
# define __BEGIN_DECLS /* nothing */
|
||||
# endif
|
||||
#endif
|
||||
#ifndef __END_DECLS
|
||||
# ifdef __cplusplus
|
||||
# define __END_DECLS }
|
||||
# else
|
||||
# define __END_DECLS /* nothing */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
# if defined __GNUC__ && defined __GNUC_VERSION__
|
||||
# define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
# else
|
||||
# define __GNUC_PREREQ(maj, min) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __THROW
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __nonnull
|
||||
# if __GNUC_PREREQ (3,3)
|
||||
# define __nonnull(params) __attribute__ ((__nonnull__ params))
|
||||
# else
|
||||
# define __nonnull(params)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* getopt_cdefs.h */
|
96
lib/getopt_core.h
Normal file
96
lib/getopt_core.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
/* Declarations for getopt (basic, portable features only).
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
The GNU C Library 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 3 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_CORE_H
|
||||
#define _GETOPT_CORE_H 1
|
||||
|
||||
/* This header should not be used directly; include getopt.h or
|
||||
unistd.h instead. Unlike most bits headers, it does not have
|
||||
a protective #error, because the guard macro for getopt.h in
|
||||
gnulib is not fixed. */
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* For communication from 'getopt' to the caller.
|
||||
When 'getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when 'ordering' is RETURN_IN_ORDER,
|
||||
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
|
||||
and for communication between successive calls to 'getopt'.
|
||||
|
||||
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
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, 'optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message 'getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* 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 '\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. */
|
||||
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
||||
__THROW __nonnull ((2, 3));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* getopt_core.h */
|
77
lib/getopt_ext.h
Normal file
77
lib/getopt_ext.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* Declarations for getopt (GNU extensions).
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
The GNU C Library 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 3 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_EXT_H
|
||||
#define _GETOPT_EXT_H 1
|
||||
|
||||
/* This header should not be used directly; include getopt.h instead.
|
||||
Unlike most bits headers, it does not have a protective #error,
|
||||
because the guard macro for getopt.h in gnulib is not fixed. */
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* 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
|
||||
zero.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
left unchanged if the option is not found.
|
||||
|
||||
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
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero 'flag' field, 'getopt'
|
||||
returns the contents of the 'val' field. */
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
/* Names for the values of the 'has_arg' field of 'struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW __nonnull ((2, 3));
|
||||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW __nonnull ((2, 3));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* getopt_ext.h */
|
|
@ -1,6 +1,7 @@
|
|||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
This file is part of the GNU C Library and is also part of gnulib.
|
||||
Patches to this file should be submitted to both projects.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
|
@ -17,14 +18,14 @@
|
|||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_INT_H
|
||||
#define _GETOPT_INT_H 1
|
||||
#define _GETOPT_INT_H 1
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
extern int _getopt_internal (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct);
|
||||
|
||||
|
||||
/* Reentrant versions which can handle parsing multiple argument
|
||||
|
@ -32,28 +33,20 @@ extern int _getopt_internal (int ___argc, char **___argv,
|
|||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
REQUIRE_ORDER means don't recognize them as options; stop option
|
||||
processing when the first non-option is seen. This is what POSIX
|
||||
specifies should happen.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
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, 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.
|
||||
This allows options to be given in any order, even with programs
|
||||
that were not written to expect this.
|
||||
PERMUTE means permute the contents of ARGV as we scan, so that
|
||||
eventually all the non-options are at the end. This allows options
|
||||
to be given in any order, even with programs that were not written
|
||||
to expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were
|
||||
written to expect options and other ARGV-elements in any order
|
||||
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
|
||||
with character code 1. Using '-' as the first character of the
|
||||
list of option characters selects this mode of operation.
|
||||
with character code 1.
|
||||
|
||||
The special argument '--' forces an end of option-scanning regardless
|
||||
of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
|
||||
|
@ -91,11 +84,6 @@ struct _getopt_data
|
|||
/* See __ord above. */
|
||||
enum __ord __ordering;
|
||||
|
||||
/* If the POSIXLY_CORRECT environment variable is set
|
||||
or getopt was called. */
|
||||
int __posixly_correct;
|
||||
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
|
@ -104,32 +92,27 @@ struct _getopt_data
|
|||
|
||||
int __first_nonopt;
|
||||
int __last_nonopt;
|
||||
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
int __nonoption_flags_max_len;
|
||||
int __nonoption_flags_len;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
||||
default values and to clear the initialization flag. */
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
|
||||
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 __posixly_correct);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, struct _getopt_data *__data,
|
||||
int __posixly_correct);
|
||||
|
||||
extern int _getopt_long_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_only_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
#endif /* getopt_int.h */
|
||||
|
|
54
lib/getopt_pfx_core.h
Normal file
54
lib/getopt_pfx_core.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* getopt (basic, portable features) gnulib wrapper header.
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
||||
gnulib 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 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
gnulib 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with gnulib; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_PFX_CORE_H
|
||||
#define _GETOPT_PFX_CORE_H 1
|
||||
|
||||
/* This header should not be used directly; include getopt.h or
|
||||
unistd.h instead. It does not have a protective #error, because
|
||||
the guard macro for getopt.h in gnulib is not fixed. */
|
||||
|
||||
/* Standalone applications should #define __GETOPT_PREFIX to an
|
||||
identifier that prefixes the external functions and variables
|
||||
defined in getopt_core.h and getopt_ext.h. Systematically
|
||||
rename identifiers so that they do not collide with the system
|
||||
functions and variables. Renaming avoids problems with some
|
||||
compilers and linkers. */
|
||||
#ifdef __GETOPT_PREFIX
|
||||
# ifndef __GETOPT_ID
|
||||
# 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)
|
||||
# endif
|
||||
# undef getopt
|
||||
# undef optarg
|
||||
# undef opterr
|
||||
# undef optind
|
||||
# undef optopt
|
||||
# define getopt __GETOPT_ID (getopt)
|
||||
# define optarg __GETOPT_ID (optarg)
|
||||
# define opterr __GETOPT_ID (opterr)
|
||||
# define optind __GETOPT_ID (optind)
|
||||
# define optopt __GETOPT_ID (optopt)
|
||||
#endif
|
||||
|
||||
#include <getopt_core.h>
|
||||
|
||||
#endif /* getopt_pfx_core.h */
|
64
lib/getopt_pfx_ext.h
Normal file
64
lib/getopt_pfx_ext.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* getopt (GNU extensions) gnulib wrapper header.
|
||||
Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
This file is part of gnulib.
|
||||
Unlike most of the getopt implementation, it is NOT shared
|
||||
with the GNU C Library.
|
||||
|
||||
gnulib 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 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
gnulib 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with gnulib; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_PFX_EXT_H
|
||||
#define _GETOPT_PFX_EXT_H 1
|
||||
|
||||
/* This header should not be used directly; include getopt.h instead.
|
||||
It does not have a protective #error, because the guard macro for
|
||||
getopt.h in gnulib is not fixed. */
|
||||
|
||||
/* Standalone applications should #define __GETOPT_PREFIX to an
|
||||
identifier that prefixes the external functions and variables
|
||||
defined in getopt_core.h and getopt_ext.h. Systematically
|
||||
rename identifiers so that they do not collide with the system
|
||||
functions and variables. Renaming avoids problems with some
|
||||
compilers and linkers. */
|
||||
#ifdef __GETOPT_PREFIX
|
||||
# ifndef __GETOPT_ID
|
||||
# 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)
|
||||
# endif
|
||||
# undef getopt_long
|
||||
# undef getopt_long_only
|
||||
# undef option
|
||||
# define getopt_long __GETOPT_ID (getopt_long)
|
||||
# define getopt_long_only __GETOPT_ID (getopt_long_only)
|
||||
# define option __GETOPT_ID (option)
|
||||
#endif
|
||||
|
||||
/* Standalone applications get correct prototypes for getopt_long and
|
||||
getopt_long_only; they declare "char **argv". For backward
|
||||
compatibility with old applications, if __GETOPT_PREFIX is not
|
||||
defined, we supply GNU-libc-compatible, but incorrect, prototypes
|
||||
using "char *const *argv". (GNU libc is stuck with the incorrect
|
||||
prototypes, as they are baked into older versions of LSB.) */
|
||||
#ifndef __getopt_argv_const
|
||||
# if defined __GETOPT_PREFIX
|
||||
# define __getopt_argv_const /* empty */
|
||||
# else
|
||||
# define __getopt_argv_const const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <getopt_ext.h>
|
||||
|
||||
#endif /* getopt_pfx_ext.h */
|
|
@ -84,6 +84,7 @@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
|
|||
ERRNO_H = @ERRNO_H@
|
||||
EXECINFO_H = @EXECINFO_H@
|
||||
EXEEXT = @EXEEXT@
|
||||
FIND_DELETE = @FIND_DELETE@
|
||||
FIRSTFILE_OBJ = @FIRSTFILE_OBJ@
|
||||
FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
|
||||
FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
|
||||
|
@ -94,6 +95,7 @@ GCONF_CFLAGS = @GCONF_CFLAGS@
|
|||
GCONF_LIBS = @GCONF_LIBS@
|
||||
GETADDRINFO_A_LIBS = @GETADDRINFO_A_LIBS@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
|
||||
GETOPT_H = @GETOPT_H@
|
||||
GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@
|
||||
GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@
|
||||
|
@ -488,6 +490,7 @@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@
|
|||
HAVE_SYMLINK = @HAVE_SYMLINK@
|
||||
HAVE_SYMLINKAT = @HAVE_SYMLINKAT@
|
||||
HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
|
||||
HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
|
||||
HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
|
||||
HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
|
||||
HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
|
||||
|
@ -1511,11 +1514,11 @@ endif
|
|||
## begin gnulib module getopt-posix
|
||||
ifeq (,$(OMIT_GNULIB_MODULE_getopt-posix))
|
||||
|
||||
BUILT_SOURCES += $(GETOPT_H)
|
||||
BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H)
|
||||
|
||||
# We need the following in order to create <getopt.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
|
||||
getopt.h: getopt.in.h $(top_builddir)/config.status
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||
|
@ -1524,13 +1527,21 @@ getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
|
|||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/getopt.in.h; \
|
||||
} > $@-t && \
|
||||
mv -f $@-t $@
|
||||
MOSTLYCLEANFILES += getopt.h getopt.h-t
|
||||
|
||||
EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h
|
||||
getopt_cdefs.h: getopt_cdefs.in.h $(top_builddir)/config.status
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
|
||||
< $(srcdir)/getopt_cdefs.in.h; \
|
||||
} > $@-t && \
|
||||
mv -f $@-t $@
|
||||
|
||||
MOSTLYCLEANFILES += getopt.h getopt.h-t getopt_cdefs.h getopt_cdefs.h-t
|
||||
|
||||
EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_cdefs.in.h getopt_core.h getopt_ext.h getopt_int.h getopt_pfx_core.h getopt_pfx_ext.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
|
||||
|
||||
|
|
|
@ -246,7 +246,8 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
|||
md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 63;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
|
||||
memcpy (ctx->buffer,
|
||||
&((char *) ctx->buffer)[(left_over + add) & ~63],
|
||||
ctx->buflen);
|
||||
|
@ -288,6 +289,8 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
|
|||
{
|
||||
md5_process_block (ctx->buffer, 64, ctx);
|
||||
left_over -= 64;
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because left_over ≤ 64. */
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
ctx->buflen = left_over;
|
||||
|
|
|
@ -74,8 +74,8 @@ struct md5_ctx
|
|||
uint32_t D;
|
||||
|
||||
uint32_t total[2];
|
||||
uint32_t buflen;
|
||||
uint32_t buffer[32];
|
||||
uint32_t buflen; /* ≥ 0, ≤ 128 */
|
||||
uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -233,7 +233,8 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
|||
sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 63;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
|
||||
memcpy (ctx->buffer,
|
||||
&((char *) ctx->buffer)[(left_over + add) & ~63],
|
||||
ctx->buflen);
|
||||
|
@ -275,6 +276,8 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
|||
{
|
||||
sha1_process_block (ctx->buffer, 64, ctx);
|
||||
left_over -= 64;
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because left_over ≤ 64. */
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
ctx->buflen = left_over;
|
||||
|
|
|
@ -46,8 +46,8 @@ struct sha1_ctx
|
|||
uint32_t E;
|
||||
|
||||
uint32_t total[2];
|
||||
uint32_t buflen;
|
||||
uint32_t buffer[32];
|
||||
uint32_t buflen; /* ≥ 0, ≤ 128 */
|
||||
uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
|
||||
};
|
||||
|
||||
/* Initialize structure containing state of computation. */
|
||||
|
|
|
@ -366,7 +366,8 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
|
|||
sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
|
||||
|
||||
ctx->buflen &= 63;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
|
||||
memcpy (ctx->buffer,
|
||||
&((char *) ctx->buffer)[(left_over + add) & ~63],
|
||||
ctx->buflen);
|
||||
|
@ -408,6 +409,8 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
|
|||
{
|
||||
sha256_process_block (ctx->buffer, 64, ctx);
|
||||
left_over -= 64;
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because left_over ≤ 64. */
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
ctx->buflen = left_over;
|
||||
|
|
|
@ -44,8 +44,8 @@ struct sha256_ctx
|
|||
uint32_t state[8];
|
||||
|
||||
uint32_t total[2];
|
||||
size_t buflen;
|
||||
uint32_t buffer[32];
|
||||
size_t buflen; /* ≥ 0, ≤ 128 */
|
||||
uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
|
||||
};
|
||||
|
||||
/* Initialize structure containing state of computation. */
|
||||
|
|
|
@ -374,7 +374,8 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
|||
sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx);
|
||||
|
||||
ctx->buflen &= 127;
|
||||
/* The regions in the following copy operation cannot overlap. */
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because ctx->buflen < 128 ≤ (left_over + add) & ~127. */
|
||||
memcpy (ctx->buffer,
|
||||
&((char *) ctx->buffer)[(left_over + add) & ~127],
|
||||
ctx->buflen);
|
||||
|
@ -416,6 +417,8 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
|
|||
{
|
||||
sha512_process_block (ctx->buffer, 128, ctx);
|
||||
left_over -= 128;
|
||||
/* The regions in the following copy operation cannot overlap,
|
||||
because left_over ≤ 128. */
|
||||
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
|
||||
}
|
||||
ctx->buflen = left_over;
|
||||
|
|
|
@ -44,8 +44,8 @@ struct sha512_ctx
|
|||
u64 state[8];
|
||||
|
||||
u64 total[2];
|
||||
size_t buflen;
|
||||
u64 buffer[32];
|
||||
size_t buflen; /* ≥ 0, ≤ 256 */
|
||||
u64 buffer[32]; /* 256 bytes; the first buflen bytes are in use */
|
||||
};
|
||||
|
||||
/* Initialize structure containing state of computation. */
|
||||
|
|
|
@ -130,8 +130,8 @@
|
|||
/* Get getopt(), optarg, optind, opterr, optopt.
|
||||
But avoid namespace pollution on glibc systems. */
|
||||
#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
|
||||
# define __need_getopt
|
||||
# include <getopt.h>
|
||||
# include <getopt_cdefs.h>
|
||||
# include <getopt_pfx_core.h>
|
||||
#endif
|
||||
|
||||
#ifndef _GL_INLINE_HEADER_BEGIN
|
||||
|
|
22
m4/getopt.m4
22
m4/getopt.m4
|
@ -1,4 +1,4 @@
|
|||
# getopt.m4 serial 44
|
||||
# getopt.m4 serial 45
|
||||
dnl Copyright (C) 2002-2006, 2008-2017 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -33,8 +33,6 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
|
|||
AC_DEFUN([gl_FUNC_GETOPT_GNU],
|
||||
[
|
||||
m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
|
||||
|
||||
AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
|
||||
])
|
||||
|
||||
# Determine whether to replace the entire getopt facility.
|
||||
|
@ -354,15 +352,19 @@ dnl is ambiguous with environment values that contain newlines.
|
|||
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
|
||||
[
|
||||
GETOPT_H=getopt.h
|
||||
AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
|
||||
if test $ac_cv_header_sys_cdefs_h = yes; then
|
||||
HAVE_SYS_CDEFS_H=1
|
||||
else
|
||||
HAVE_SYS_CDEFS_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_SYS_CDEFS_H])
|
||||
|
||||
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
|
||||
[Define to rpl_ if the getopt replacement functions and variables
|
||||
should be used.])
|
||||
GETOPT_H=getopt.h
|
||||
GETOPT_CDEFS_H=getopt_cdefs.h
|
||||
AC_SUBST([GETOPT_H])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/getopt*.
|
||||
AC_DEFUN([gl_PREREQ_GETOPT],
|
||||
[
|
||||
AC_CHECK_DECLS_ONCE([getenv])
|
||||
AC_SUBST([GETOPT_CDEFS_H])
|
||||
])
|
||||
|
|
|
@ -259,19 +259,10 @@ AC_DEFUN([gl_INIT],
|
|||
fi
|
||||
gl_STDLIB_MODULE_INDICATOR([getloadavg])
|
||||
gl_FUNC_GETOPT_GNU
|
||||
if test $REPLACE_GETOPT = 1; then
|
||||
AC_LIBOBJ([getopt])
|
||||
AC_LIBOBJ([getopt1])
|
||||
gl_PREREQ_GETOPT
|
||||
dnl Arrange for unistd.h to include getopt.h.
|
||||
GNULIB_GL_UNISTD_H_GETOPT=1
|
||||
fi
|
||||
AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
|
||||
gl_FUNC_GETOPT_POSIX
|
||||
if test $REPLACE_GETOPT = 1; then
|
||||
AC_LIBOBJ([getopt])
|
||||
AC_LIBOBJ([getopt1])
|
||||
gl_PREREQ_GETOPT
|
||||
dnl Arrange for unistd.h to include getopt.h.
|
||||
GNULIB_GL_UNISTD_H_GETOPT=1
|
||||
fi
|
||||
|
@ -911,7 +902,12 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/getopt.c
|
||||
lib/getopt.in.h
|
||||
lib/getopt1.c
|
||||
lib/getopt_cdefs.in.h
|
||||
lib/getopt_core.h
|
||||
lib/getopt_ext.h
|
||||
lib/getopt_int.h
|
||||
lib/getopt_pfx_core.h
|
||||
lib/getopt_pfx_ext.h
|
||||
lib/gettext.h
|
||||
lib/gettime.c
|
||||
lib/gettimeofday.c
|
||||
|
|
Loading…
Add table
Reference in a new issue