X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=libiberty%2Fgetopt.c;h=d9c3532ce1136b41ff027439ce7ee6067a7c8673;hb=8d37573b4356a38d091b0f18b69f91797a7cef26;hp=6d6ea14c41cc4ef2f33f13977c6b26636466131e;hpb=9888440ad603c44db4908229b7ce827ca7a16eb4;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/getopt.c b/libiberty/getopt.c index 6d6ea14c41..d9c3532ce1 100644 --- a/libiberty/getopt.c +++ b/libiberty/getopt.c @@ -4,7 +4,7 @@ before changing it! Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 2004 Free Software Foundation, Inc. + 1996, 1997, 1998, 2005 Free Software Foundation, Inc. NOTE: This source is derived from an old version taken from the GNU C Library (glibc). @@ -21,7 +21,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . @@ -42,6 +42,7 @@ # endif #endif +#include "ansidecl.h" #include /* Comment out all this code if we are using the GNU C Library, and are not @@ -90,9 +91,6 @@ # endif #endif -/* Needed for ATTRIBUTE_UNUSED. */ -#include - /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. @@ -215,14 +213,20 @@ static char *posixly_correct; /* Avoid depending on library functions or files whose names are inconsistent. */ -#ifndef getenv -extern char *getenv (); +#if HAVE_STDLIB_H && HAVE_DECL_GETENV +# include +#elif !defined(getenv) +# ifdef __cplusplus +extern "C" { +# endif /* __cplusplus */ +extern char *getenv (const char *); +# ifdef __cplusplus +} +# endif /* __cplusplus */ #endif static char * -my_index (str, chr) - const char *str; - int chr; +my_index (const char *str, int chr) { while (*str) { @@ -310,8 +314,7 @@ static void exchange (char **); #endif static void -exchange (argv) - char **argv; +exchange (char **argv) { int bottom = first_nonopt; int middle = last_nonopt; @@ -331,7 +334,7 @@ exchange (argv) { /* We must extend the array. The user plays games with us and presents new arguments. */ - char *new_str = malloc (top + 1); + char *new_str = (char *) malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else @@ -395,10 +398,9 @@ exchange (argv) static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * -_getopt_initialize (argc, argv, optstring) - int argc ATTRIBUTE_UNUSED; - char *const *argv ATTRIBUTE_UNUSED; - const char *optstring; +_getopt_initialize (int argc ATTRIBUTE_UNUSED, + char *const *argv ATTRIBUTE_UNUSED, + const char *optstring) { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped @@ -517,13 +519,9 @@ _getopt_initialize (argc, argv, optstring) long-named options. */ int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; +_getopt_internal (int argc, char *const *argv, const char *optstring, + const struct option *longopts, + int *longind, int long_only) { optarg = NULL; @@ -973,10 +971,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) } int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; +getopt (int argc, char *const *argv, const char *optstring) { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, @@ -992,9 +987,7 @@ getopt (argc, argv, optstring) the above definition of `getopt'. */ int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { int c; int digit_optind = 0;