X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetopt.c;h=1af2a9629012667696f507ebc4cc4706862725d5;hb=c89f48f01f6047b50c1ed3c981901f620ec98f6a;hp=57fd398ef9bbb4da8de46b4f830abf2169c641d6;hpb=cb0e9ba1b4f96efd5ca7649047d6aeb8edf01e6f;p=gnulib.git diff --git a/lib/getopt.c b/lib/getopt.c index 57fd398ef..1af2a9629 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -3,7 +3,7 @@ "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94 + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -383,7 +383,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) optarg = NULL; if (optind == 0) - optstring = _getopt_initialize (optstring); + { + optstring = _getopt_initialize (optstring); + optind = 1; /* Don't scan ARGV[0], the program name. */ + } if (nextchar == NULL || *nextchar == '\0') { @@ -473,7 +476,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (longopts != NULL && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + || (long_only && (argv[optind][2] + || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; @@ -486,6 +490,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; +#ifdef lint + indfound = 0; /* Avoid spurious compiler warning. */ +#endif + /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++)