getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions". Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers. getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.
* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
New files, intended to be shared with gnulib.
* posix/bits/getopt_posix.h:
New file, not intended to be shared with gnulib.
* posix/getopt.h: Now just includes features.h,
bits/getopt_core.h, and bits/getopt_ext.h. Will
no longer be shared with gnulib.
* include/bits/getopt_core.h, include/bits/getopt_ext.h
* include/bits/getopt_posix.h: New wrappers.
* posix/Makefile: Install new headers.
* posix/unistd.h, libio/stdio.h:
Include bits/getopt_posix.h instead of getopt.h.
2017-03-25 15:24:24 +00:00
|
|
|
/* Declarations for getopt (basic, portable features only).
|
2021-01-02 19:32:25 +00:00
|
|
|
Copyright (C) 1989-2021 Free Software Foundation, Inc.
|
2017-04-05 15:04:35 +00:00
|
|
|
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.
|
getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions". Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers. getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.
* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
New files, intended to be shared with gnulib.
* posix/bits/getopt_posix.h:
New file, not intended to be shared with gnulib.
* posix/getopt.h: Now just includes features.h,
bits/getopt_core.h, and bits/getopt_ext.h. Will
no longer be shared with gnulib.
* include/bits/getopt_core.h, include/bits/getopt_ext.h
* include/bits/getopt_posix.h: New wrappers.
* posix/Makefile: Install new headers.
* posix/unistd.h, libio/stdio.h:
Include bits/getopt_posix.h instead of getopt.h.
2017-03-25 15:24:24 +00:00
|
|
|
|
|
|
|
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
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions". Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers. getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.
* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
New files, intended to be shared with gnulib.
* posix/bits/getopt_posix.h:
New file, not intended to be shared with gnulib.
* posix/getopt.h: Now just includes features.h,
bits/getopt_core.h, and bits/getopt_ext.h. Will
no longer be shared with gnulib.
* include/bits/getopt_core.h, include/bits/getopt_ext.h
* include/bits/getopt_posix.h: New wrappers.
* posix/Makefile: Install new headers.
* posix/unistd.h, libio/stdio.h:
Include bits/getopt_posix.h instead of getopt.h.
2017-03-25 15:24:24 +00:00
|
|
|
|
|
|
|
#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 */
|