From 7effd7ae99b2288452762f29cde8311ec72c2cb8 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Tue, 21 Oct 2008 12:36:43 +0000 Subject: getopt: reinstate erroneously removed getopt() reset code. --- util-linux/getopt.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'util-linux/getopt.c') diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 8b5e46c7b..fd6728731 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c @@ -157,6 +157,15 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru if (quiet_errors) /* No error reporting from getopt(3) */ opterr = 0; + /* We used it already in main() in getopt32(), + * we *must* reset getopt(3): */ +#ifdef __GLIBC__ + optind = 0; +#else /* BSD style */ + optind = 1; + /* optreset = 1; */ +#endif + while (1) { opt = #if ENABLE_GETOPT_LONG -- cgit v1.2.3