diff options
Diffstat (limited to 'libbb/getopt32.c')
-rw-r--r-- | libbb/getopt32.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index ee85181cd..f33ead1c6 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -515,6 +515,19 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | /* In case getopt32 was already called: | ||
519 | * reset the libc getopt() function, which keeps internal state. | ||
520 | * run_nofork_applet_prime() does this, but we might end up here | ||
521 | * also via gunzip_main() -> gzip_main(). Play safe. | ||
522 | */ | ||
523 | #ifdef __GLIBC__ | ||
524 | optind = 0; | ||
525 | #else /* BSD style */ | ||
526 | optind = 1; | ||
527 | /* optreset = 1; */ | ||
528 | #endif | ||
529 | /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ | ||
530 | |||
518 | pargv = NULL; | 531 | pargv = NULL; |
519 | 532 | ||
520 | /* Note: just "getopt() <= 0" will not work well for | 533 | /* Note: just "getopt() <= 0" will not work well for |