aboutsummaryrefslogtreecommitdiff
path: root/libbb/getopt32.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-20 07:52:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-20 07:52:33 +0000
commitd1660cb9ad3adb4b99c098de88f79cbeb74c3a5d (patch)
treecddc476b03fc1eb2eb95f16399b55348b306885e /libbb/getopt32.c
parent802a7be54ffcf6e45808d72e2562456bba564028 (diff)
downloadbusybox-w32-d1660cb9ad3adb4b99c098de88f79cbeb74c3a5d.tar.gz
busybox-w32-d1660cb9ad3adb4b99c098de88f79cbeb74c3a5d.tar.bz2
busybox-w32-d1660cb9ad3adb4b99c098de88f79cbeb74c3a5d.zip
ash: fix a bug in standalone mode (corrupted getopt() state)
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 43fb6eb86..49fb5335d 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