summaryrefslogtreecommitdiff
path: root/libbb/getopt32.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/getopt32.c')
-rw-r--r--libbb/getopt32.c22
1 files changed, 0 insertions, 22 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index 8fb99b6cc..ee85181cd 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -515,28 +515,6 @@ 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 *
521 * BSD-derived getopt() functions require that optind be set to 1 in
522 * order to reset getopt() state. This used to be generally accepted
523 * way of resetting getopt(). However, glibc's getopt()
524 * has additional getopt() state beyond optind, and requires that
525 * optind be set to zero to reset its state. So the unfortunate state of
526 * affairs is that BSD-derived versions of getopt() misbehave if
527 * optind is set to 0 in order to reset getopt(), and glibc's getopt()
528 * will core dump if optind is set 1 in order to reset getopt().
529 *
530 * More modern versions of BSD require that optreset be set to 1 in
531 * order to reset getopt(). Sigh. Standards, anyone?
532 */
533#ifdef __GLIBC__
534 optind = 0;
535#else /* BSD style */
536 optind = 1;
537 /* optreset = 1; */
538#endif
539 /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */
540 pargv = NULL; 518 pargv = NULL;
541 519
542 /* Note: just "getopt() <= 0" will not work well for 520 /* Note: just "getopt() <= 0" will not work well for