diff options
Diffstat (limited to 'lib/getopt1.c')
-rw-r--r-- | lib/getopt1.c | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/lib/getopt1.c b/lib/getopt1.c index 3288c72..25d7926 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c | |||
@@ -1,8 +1,6 @@ | |||
1 | /* getopt_long and getopt_long_only entry points for GNU getopt. | 1 | /* getopt_long and getopt_long_only entry points for GNU getopt. |
2 | 2 | Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004 | |
3 | Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, | 3 | Free Software Foundation, Inc. |
4 | 1997, 1998, 2003 Free Software Foundation, Inc. | ||
5 | |||
6 | This file is part of the GNU C Library. | 4 | This file is part of the GNU C Library. |
7 | 5 | ||
8 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
@@ -17,10 +15,10 @@ | |||
17 | 15 | ||
18 | You should have received a copy of the GNU General Public License along | 16 | You should have received a copy of the GNU General Public License along |
19 | with this program; if not, write to the Free Software Foundation, | 17 | with this program; if not, write to the Free Software Foundation, |
20 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
21 | 19 | ||
22 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
23 | #include <config.h> | 21 | # include <config.h> |
24 | #endif | 22 | #endif |
25 | 23 | ||
26 | #ifdef _LIBC | 24 | #ifdef _LIBC |
@@ -28,28 +26,10 @@ | |||
28 | #else | 26 | #else |
29 | # include "getopt.h" | 27 | # include "getopt.h" |
30 | #endif | 28 | #endif |
29 | #include "getopt_int.h" | ||
31 | 30 | ||
32 | #include <stdio.h> | 31 | #include <stdio.h> |
33 | 32 | ||
34 | /* Comment out all this code if we are using the GNU C Library, and are not | ||
35 | actually compiling the library itself. This code is part of the GNU C | ||
36 | Library, but also included in many other GNU distributions. Compiling | ||
37 | and linking in this code is a waste when using the GNU C library | ||
38 | (especially if it is a shared library). Rather than having every GNU | ||
39 | program understand `configure --with-gnu-libc' and omit the object files, | ||
40 | it is simpler to just do this in the source for each such file. */ | ||
41 | |||
42 | #define GETOPT_INTERFACE_VERSION 2 | ||
43 | #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 | ||
44 | #include <gnu-versions.h> | ||
45 | #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION | ||
46 | #define ELIDE_CODE | ||
47 | #endif | ||
48 | #endif | ||
49 | |||
50 | #ifndef ELIDE_CODE | ||
51 | |||
52 | |||
53 | /* This needs to come after some library #include | 33 | /* This needs to come after some library #include |
54 | to get __GNU_LIBRARY__ defined. */ | 34 | to get __GNU_LIBRARY__ defined. */ |
55 | #ifdef __GNU_LIBRARY__ | 35 | #ifdef __GNU_LIBRARY__ |
@@ -61,13 +41,20 @@ | |||
61 | #endif | 41 | #endif |
62 | 42 | ||
63 | int | 43 | int |
64 | getopt_long (int argc, | 44 | getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, |
65 | char *const *argv, | 45 | const struct option *long_options, int *opt_index) |
66 | const char *options, | ||
67 | const struct option *long_options, | ||
68 | int *opt_index) | ||
69 | { | 46 | { |
70 | return _getopt_internal (argc, argv, options, long_options, opt_index, 0); | 47 | return _getopt_internal (argc, (char **) argv, options, long_options, |
48 | opt_index, 0, 0); | ||
49 | } | ||
50 | |||
51 | int | ||
52 | _getopt_long_r (int argc, char **argv, const char *options, | ||
53 | const struct option *long_options, int *opt_index, | ||
54 | struct _getopt_data *d) | ||
55 | { | ||
56 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
57 | 0, 0, d); | ||
71 | } | 58 | } |
72 | 59 | ||
73 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. | 60 | /* Like getopt_long, but '-' as well as '--' can indicate a long option. |
@@ -76,21 +63,23 @@ getopt_long (int argc, | |||
76 | instead. */ | 63 | instead. */ |
77 | 64 | ||
78 | int | 65 | int |
79 | getopt_long_only (int argc, | 66 | getopt_long_only (int argc, char *__getopt_argv_const *argv, |
80 | char *const *argv, | ||
81 | const char *options, | 67 | const char *options, |
82 | const struct option *long_options, | 68 | const struct option *long_options, int *opt_index) |
83 | int *opt_index) | ||
84 | { | 69 | { |
85 | return _getopt_internal (argc, argv, options, long_options, opt_index, 1); | 70 | return _getopt_internal (argc, (char **) argv, options, long_options, |
71 | opt_index, 1, 0); | ||
86 | } | 72 | } |
87 | 73 | ||
88 | # ifdef _LIBC | 74 | int |
89 | libc_hidden_def (getopt_long) | 75 | _getopt_long_only_r (int argc, char **argv, const char *options, |
90 | libc_hidden_def (getopt_long_only) | 76 | const struct option *long_options, int *opt_index, |
91 | # endif | 77 | struct _getopt_data *d) |
78 | { | ||
79 | return _getopt_internal_r (argc, argv, options, long_options, opt_index, | ||
80 | 1, 0, d); | ||
81 | } | ||
92 | 82 | ||
93 | #endif /* Not ELIDE_CODE. */ | ||
94 | 83 | ||
95 | #ifdef TEST | 84 | #ifdef TEST |
96 | 85 | ||