diff --git a/configure b/configure index bc31918319..4f020cf5ff 100755 --- a/configure +++ b/configure @@ -13017,7 +13017,7 @@ for ac_func in \ futimesat \ getattrlist \ getdirentries \ - getopt_long \ + getopt_long_only \ getpagesize \ getpwuid \ gettimeofday \ diff --git a/configure.ac b/configure.ac index 1adb6fd18d..b1e479d222 100644 --- a/configure.ac +++ b/configure.ac @@ -2019,7 +2019,7 @@ AC_CHECK_FUNCS(\ futimesat \ getattrlist \ getdirentries \ - getopt_long \ + getopt_long_only \ getpagesize \ getpwuid \ gettimeofday \ diff --git a/include/config.h.in b/include/config.h.in index 8dc812b035..68220527e8 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -206,8 +206,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H -/* Define to 1 if you have the `getopt_long' function. */ -#undef HAVE_GETOPT_LONG +/* Define to 1 if you have the `getopt_long_only' function. */ +#undef HAVE_GETOPT_LONG_ONLY /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE diff --git a/libs/port/getopt.c b/libs/port/getopt.c index eeb64a6e7d..e38d137048 100644 --- a/libs/port/getopt.c +++ b/libs/port/getopt.c @@ -33,7 +33,7 @@ # include #endif -#ifdef HAVE_GETOPT_LONG +#ifdef HAVE_GETOPT_LONG_ONLY #define ELIDE_CODE #endif @@ -218,26 +218,7 @@ static char *posixly_correct; # include # endif -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv -extern char *getenv (); -#endif - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} +# define my_index strchr /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ @@ -1196,10 +1177,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, NULL, diff --git a/libs/port/getopt1.c b/libs/port/getopt1.c index 37249b616b..5cf9f01d78 100644 --- a/libs/port/getopt1.c +++ b/libs/port/getopt1.c @@ -24,7 +24,7 @@ #include #endif -#ifdef HAVE_GETOPT_LONG +#ifdef HAVE_GETOPT_LONG_ONLY #define ELIDE_CODE #endif @@ -74,12 +74,7 @@ #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); } @@ -90,12 +85,7 @@ 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); }