summaryrefslogtreecommitdiff
path: root/lib/long-options.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-01-25 05:37:15 +0000
committerJim Meyering <jim@meyering.net>1997-01-25 05:37:15 +0000
commit175fb661e0315144cf97707c3f17cccffb3fc64d (patch)
treea18820b4779bf056d9d0973af3727575d8f7978a /lib/long-options.c
parent50c04a9d3eaff68464906f321989ee152a06a926 (diff)
downloadcoreutils-175fb661e0315144cf97707c3f17cccffb3fc64d.tar.xz
(parse_long_options): Reset optind to zero
before just returning so that getopt internals get initialized from the probably-new parameters when/if getopt is called later.
Diffstat (limited to 'lib/long-options.c')
-rw-r--r--lib/long-options.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/long-options.c b/lib/long-options.c
index 810965f06..cd2c68d64 100644
--- a/lib/long-options.c
+++ b/lib/long-options.c
@@ -46,10 +46,8 @@ parse_long_options (argc, argv, command_name, package, version, usage)
{
int c;
int saved_opterr;
- int saved_optind;
saved_opterr = opterr;
- saved_optind = optind;
/* Don't print an error message for unrecognized options. */
opterr = 0;
@@ -75,6 +73,7 @@ parse_long_options (argc, argv, command_name, package, version, usage)
/* Restore previous value. */
opterr = saved_opterr;
- /* Restore optind in case it has advanced past a leading `--'. */
- optind = saved_optind;
+ /* Reset this to zero so that getopt internals get initialized from
+ the probably-new parameters when/if getopt is called later. */
+ optind = 0;
}