Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
76d74c1a
Commit
76d74c1a
authored
May 13, 2014
by
Niels Möller
Browse files
Updated getopt files, from glibc-2.19.
parent
56e05f0b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
76d74c1a
...
...
@@ -3,6 +3,12 @@
* testsuite/nettle-pbkdf2-test: Avoid the bash construction
${#foo}.
* getopt.c: Copied from glibc tree, tag glibc-2.19.
* getopt.h: Likewise.
* getopt1.c: Likewise.
* getopt_int.h: New file, also copied from glibc.
* Makefile.in (DISTFILES): Added getopt_int.h.
2014-05-09 Niels Möller <nisse@lysator.liu.se>
* mini-gmp.c: Updated, use version from gmp-6.0.0.
...
...
Makefile.in
View file @
76d74c1a
...
...
@@ -191,7 +191,8 @@ SOURCES = $(nettle_SOURCES) $(hogweed_SOURCES) \
$(getopt_SOURCES)
$(internal_SOURCES)
\
aesdata.c desdata.c twofishdata.c shadata.c gcmdata.c eccdata.c
DISTFILES
=
$(SOURCES)
$(HEADERS)
getopt.h .bootstrap run-tests
\
DISTFILES
=
$(SOURCES)
$(HEADERS)
getopt.h getopt_int.h
\
.bootstrap run-tests
\
aclocal.m4 configure.ac
\
configure stamp-h.in
\
config.guess config.sub install-sh texinfo.tex
\
...
...
getopt.c
View file @
76d74c1a
This diff is collapsed.
Click to expand it.
getopt.h
View file @
76d74c1a
/* Declarations for getopt.
Copyright (C) 1989-
1994, 1996-1999, 2001
Free Software Foundation, Inc.
Copyright (C) 1989-
2014
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Th
is program
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 2, or (at your option)
any later version.
Th
e GNU C Library
is free software; you can redistribute it and/or
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.
Th
is program
is distributed in the hope that it will be useful,
Th
e 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.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
Lesser
General Public License for more details.
You should have received a copy of the GNU General Public
License
along with th
is program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA
. */
You should have received a copy of the GNU
Lesser
General Public
License
along with th
e GNU C Library; if not, see
<http://www.gnu.org/licenses/>
. */
#ifndef _GETOPT_H
...
...
@@ -33,6 +33,17 @@
# 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
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -92,11 +103,7 @@ extern int optopt;
struct
option
{
# if (defined __STDC__ && __STDC__) || defined __cplusplus
const
char
*
name
;
# else
char
*
name
;
# endif
/* 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
;
...
...
@@ -136,38 +143,43 @@ struct option
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if (defined __STDC__ && __STDC__) || defined __cplusplus
# ifdef __GNU_LIBRARY__
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern
int
getopt
(
int
argc
,
char
*
const
*
argv
,
const
char
*
shortopts
)
;
# else
/* not __GNU_LIBRARY__ */
extern
int
getopt
();
#
endif
/* __GNU_LIBRARY__ */
# ifndef __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
,
const
char
*
shortopts
,
const
struct
option
*
longopts
,
int
*
longind
);
/* Internal only. Users should not call this directly. */
extern
int
_
getopt_internal
(
int
argc
,
char
*
const
*
argv
,
const
char
*
shortopts
,
const
struct
option
*
longopts
,
int
*
longind
,
int
long_only
);
extern
int
getopt
(
int
___
argc
,
char
*
const
*
___
argv
,
const
char
*
__
shortopts
)
__THROW
;
#
if defined __need_getopt && defined __USE_POSIX2 \
&& !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
/* The GNU getopt has more functionality than the standard version. The
additional functionality can be disable at runtime. This redirection
helps to also do this at runtime. */
# ifdef __REDIRECT
extern
int
__REDIRECT_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
;
# define getopt __posix_getopt
# endif
# endif
#else
/* not __
STDC
__ */
#else
/* not __
GNU_LIBRARY
__ */
extern
int
getopt
();
# ifndef __need_getopt
extern
int
getopt_long
();
extern
int
getopt_long_only
();
#endif
/* __GNU_LIBRARY__ */
extern
int
_getopt_internal
();
# endif
#endif
/* __STDC__ */
#ifndef __need_getopt
extern
int
getopt_long
(
int
___argc
,
char
*
const
*
___argv
,
const
char
*
__shortopts
,
const
struct
option
*
__longopts
,
int
*
__longind
)
__THROW
;
extern
int
getopt_long_only
(
int
___argc
,
char
*
const
*
___argv
,
const
char
*
__shortopts
,
const
struct
option
*
__longopts
,
int
*
__longind
)
__THROW
;
#endif
#ifdef __cplusplus
}
...
...
getopt1.c
View file @
76d74c1a
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
Copyright (C) 1987-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Th
is program
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 2, or (at your option)
any later version.
Th
e GNU C Library
is free software; you can redistribute it and/or
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.
Th
is program
is distributed in the hope that it will be useful,
Th
e 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.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
Lesser
General Public License for more details.
You should have received a copy of the GNU General Public
License
along with th
is program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA
. */
You should have received a copy of the GNU
Lesser
General Public
License
along with th
e GNU C Library; if not, see
<http://www.gnu.org/licenses/>
. */
#ifdef HAVE_CONFIG_H
#include
<config.h>
#endif
#include
"getopt.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#ifdef _LIBC
# include <getopt.h>
#else
# include "getopt.h"
#endif
#include
"getopt_int.h"
#include
<stdio.h>
...
...
@@ -63,14 +59,19 @@
#endif
int
getopt_long
(
argc
,
argv
,
options
,
long_options
,
opt_index
)
int
argc
;
char
*
const
*
argv
;
const
char
*
options
;
const
struct
option
*
long_options
;
int
*
opt_index
;
getopt_long
(
int
argc
,
char
*
const
*
argv
,
const
char
*
options
,
const
struct
option
*
long_options
,
int
*
opt_index
)
{
return
_getopt_internal
(
argc
,
argv
,
options
,
long_options
,
opt_index
,
0
);
return
_getopt_internal
(
argc
,
argv
,
options
,
long_options
,
opt_index
,
0
,
0
);
}
int
_getopt_long_r
(
int
argc
,
char
*
const
*
argv
,
const
char
*
options
,
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
);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
...
...
@@ -79,16 +80,20 @@ getopt_long (argc, argv, options, long_options, opt_index)
instead. */
int
getopt_long_only
(
argc
,
argv
,
options
,
long_options
,
opt_index
)
int
argc
;
char
*
const
*
argv
;
const
char
*
options
;
const
struct
option
*
long_options
;
int
*
opt_index
;
getopt_long_only
(
int
argc
,
char
*
const
*
argv
,
const
char
*
options
,
const
struct
option
*
long_options
,
int
*
opt_index
)
{
return
_getopt_internal
(
argc
,
argv
,
options
,
long_options
,
opt_index
,
1
);
return
_getopt_internal
(
argc
,
argv
,
options
,
long_options
,
opt_index
,
1
,
0
);
}
int
_getopt_long_only_r
(
int
argc
,
char
*
const
*
argv
,
const
char
*
options
,
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
);
}
#endif
/* Not ELIDE_CODE. */
...
...
@@ -97,9 +102,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
#include
<stdio.h>
int
main
(
argc
,
argv
)
int
argc
;
char
**
argv
;
main
(
int
argc
,
char
**
argv
)
{
int
c
;
int
digit_optind
=
0
;
...
...
getopt_int.h
0 → 100644
View file @
76d74c1a
/* Internal declarations for getopt.
Copyright (C) 1989-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
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.
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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _GETOPT_INT_H
#define _GETOPT_INT_H 1
extern
int
_getopt_internal
(
int
___argc
,
char
*
const
*
___argv
,
const
char
*
__shortopts
,
const
struct
option
*
__longopts
,
int
*
__longind
,
int
__long_only
,
int
posixly_correct
);
/* Reentrant versions which can handle parsing multiple argument
vectors at the same time. */
/* Data type for reentrant functions. */
struct
_getopt_data
{
/* These have exactly the same meaning as the corresponding global
variables, except that they are used for the reentrant
versions of getopt. */
int
optind
;
int
opterr
;
int
optopt
;
char
*
optarg
;
/* Internal members. */
/* True if the internal members have been initialized. */
int
__initialized
;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
char
*
__nextchar
;
/* 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 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.
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.
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.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
enum
{
REQUIRE_ORDER
,
PERMUTE
,
RETURN_IN_ORDER
}
__ordering
;
/* If the POSIXLY_CORRECT environment variable is set. */
int
__posixly_correct
;
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first
of them; `last_nonopt' is the index after the last of them. */
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 }
extern
int
_getopt_internal_r
(
int
___argc
,
char
*
const
*
___argv
,
const
char
*
__shortopts
,
const
struct
option
*
__longopts
,
int
*
__longind
,
int
__long_only
,
struct
_getopt_data
*
__data
,
int
posixly_correct
);
extern
int
_getopt_long_r
(
int
___argc
,
char
*
const
*
___argv
,
const
char
*
__shortopts
,
const
struct
option
*
__longopts
,
int
*
__longind
,
struct
_getopt_data
*
__data
);
extern
int
_getopt_long_only_r
(
int
___argc
,
char
*
const
*
___argv
,
const
char
*
__shortopts
,
const
struct
option
*
__longopts
,
int
*
__longind
,
struct
_getopt_data
*
__data
);
#endif
/* getopt_int.h */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment