diff options
author | Zack Weinberg <zackw@panix.com> | 2017-03-31 07:58:07 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-04-07 07:47:29 -0400 |
commit | 7f71f9c1d6735e713de193faf03edb37c4bcb563 (patch) | |
tree | 954e0d212d66c562062f4b193d9478aa9e06560d /posix/getopt1.c | |
parent | 7784135eb0de2d083bf3460c1386aee1c056e96e (diff) | |
download | glibc-7f71f9c1d6735e713de193faf03edb37c4bcb563.tar glibc-7f71f9c1d6735e713de193faf03edb37c4bcb563.tar.gz glibc-7f71f9c1d6735e713de193faf03edb37c4bcb563.tar.bz2 glibc-7f71f9c1d6735e713de193faf03edb37c4bcb563.zip |
getopt: merge straightforward changes from gnulib
This covers changes with little or no consequences when the code is
used in glibc.
* posix/getopt_int.h: Include getopt.h.
Use impl-namespace names for all arguments to _getopt_internal and
_getopt_internal_r.
Declare __ordering enum outside the struct.
Harmonize comments with gnulib.
* posix/getopt1.c: Simplify #ifdeffage at top of file. Remove
ELIDE_CODE logic entirely. Move inclusion of stdlib.h to
#ifdef TEST block and make unconditional. Do not define NULL.
* posix/getopt.c: Partial merge from gnulib, covering the
initial includes and global declarations, commentary, and
a couple of semantically-neutral code changes.
Diffstat (limited to 'posix/getopt1.c')
-rw-r--r-- | posix/getopt1.c | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/posix/getopt1.c b/posix/getopt1.c index b9a853804a..b4ae6e48f2 100644 --- a/posix/getopt1.c +++ b/posix/getopt1.c @@ -16,48 +16,13 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#ifdef HAVE_CONFIG_H -#include <config.h> +#ifndef _LIBC +#include "config.h" #endif -#ifdef _LIBC -# include <getopt.h> -#else -# include "getopt.h" -#endif +#include "getopt.h" #include "getopt_int.h" -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - 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 - 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. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* 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 *const *argv, const char *options, const struct option *long_options, int *opt_index) @@ -95,11 +60,11 @@ _getopt_long_only_r (int argc, char *const *argv, const char *options, 1, d, 0); } -#endif /* Not ELIDE_CODE. */ #ifdef TEST #include <stdio.h> +#include <stdlib.h> int main (int argc, char **argv) |