diff --git a/fallback.c b/fallback.c index 8f206dbef..9ab246208 100644 --- a/fallback.c +++ b/fallback.c @@ -1076,3 +1076,18 @@ int killpg( int pgr, int sig ) return kill( -pgr, sig ); } #endif + +#ifndef HAVE_WORKING_GETOPT_LONG + +int getopt_long(int argc, + char * const argv[], + const char *optstring, + const struct option *longopts, + int *longindex) +{ + return getopt( argc, argv, optstring ); +} + + +#endif + diff --git a/fallback.h b/fallback.h index 323a690ca..5f3b1af7a 100644 --- a/fallback.h +++ b/fallback.h @@ -385,5 +385,37 @@ extern int _nl_msg_cat_cntr; int killpg( int pgr, int sig ); #endif + +#ifndef HAVE_WORKING_GETOPT_LONG + +struct option +{ + const char *name; + int has_arg; + int *flag; + int val; +} + ; + +#ifndef no_argument +#define no_argument 0 +#endif + +#ifndef required_argument +#define required_argument 1 +#endif + +#ifndef optional_argument +#define optional_argument 2 +#endif + +int getopt_long(int argc, + char * const argv[], + const char *optstring, + const struct option *longopts, + int *longindex); + +#endif + #endif diff --git a/fishd.c b/fishd.c index dd2b6af6b..4c6b6b312 100644 --- a/fishd.c +++ b/fishd.c @@ -494,7 +494,6 @@ int main( int argc, char ** argv ) */ while( 1 ) { -#ifdef HAVE_WORKING_GETOPT_LONG static struct option long_options[] = { @@ -520,11 +519,6 @@ int main( int argc, char ** argv ) long_options, &opt_index ); -#else - int opt = getopt( argc, - argv, - GETOPT_STRING ); -#endif if( opt == -1 ) break; diff --git a/main.c b/main.c index bb379c8b8..a19c47ec4 100644 --- a/main.c +++ b/main.c @@ -123,7 +123,6 @@ int main( int argc, char **argv ) while( 1 ) { -#ifdef HAVE_WORKING_GETOPT_LONG static struct option long_options[] = { @@ -173,11 +172,6 @@ int main( int argc, char **argv ) long_options, &opt_index ); -#else - int opt = getopt( argc, - argv, - GETOPT_STRING ); -#endif if( opt == -1 ) break; diff --git a/mimedb.c b/mimedb.c index 09ee17c7f..ac1b8ec6d 100644 --- a/mimedb.c +++ b/mimedb.c @@ -1168,7 +1168,6 @@ int main (int argc, char *argv[]) */ while( 1 ) { -#ifdef HAVE_WORKING_GETOPT_LONG static struct option long_options[] = { @@ -1222,11 +1221,6 @@ int main (int argc, char *argv[]) long_options, &opt_index ); -#else - int opt = getopt( argc, - argv, - GETOPT_STRING ); -#endif if( opt == -1 ) break; diff --git a/set_color.c b/set_color.c index ab376a9db..54ca87ec9 100644 --- a/set_color.c +++ b/set_color.c @@ -153,7 +153,6 @@ int main( int argc, char **argv ) while( 1 ) { -#ifdef HAVE_WORKING_GETOPT_LONG static struct option long_options[] = { @@ -194,11 +193,7 @@ int main( int argc, char **argv ) GETOPT_STRING, long_options, &opt_index ); -#else - int opt = getopt( argc, - argv, - GETOPT_STRING ); -#endif + if( opt == -1 ) break;