From 8cc396bce284ce7644f2e97c866b697670c3564c Mon Sep 17 00:00:00 2001
From: Jim Meyering <jim@meyering.net>
Date: Sat, 25 Jan 1997 05:37:15 +0000
Subject: [PATCH] (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.

---
 lib/long-options.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/long-options.c b/lib/long-options.c
index 810965f066..cd2c68d64d 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;
 }
-- 
2.39.5