summaryrefslogtreecommitdiff
path: root/libbb/getopt32.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-11-29 06:43:05 +0000
committerDenis Vlasenko2008-11-29 06:43:05 +0000
commit9343da45d3f226cc8b45879ac8dbacac2911cdd8 (patch)
tree9e76d089f819e99fc7e57f3fb771af834cdc7c5a /libbb/getopt32.c
parent84641942e5366b2e09367ba4f4376c99f15ecc8e (diff)
downloadbusybox-9343da45d3f226cc8b45879ac8dbacac2911cdd8.zip
busybox-9343da45d3f226cc8b45879ac8dbacac2911cdd8.tar.gz
apply post-1.12.2 fixes, bump version to 1.12.31_12_3
Diffstat (limited to 'libbb/getopt32.c')
-rw-r--r--libbb/getopt32.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index ee85181..f33ead1 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -515,6 +515,19 @@ getopt32(char **argv, const char *applet_opts, ...)
}
}
+ /* In case getopt32 was already called:
+ * reset the libc getopt() function, which keeps internal state.
+ * run_nofork_applet_prime() does this, but we might end up here
+ * also via gunzip_main() -> gzip_main(). Play safe.
+ */
+#ifdef __GLIBC__
+ optind = 0;
+#else /* BSD style */
+ optind = 1;
+ /* optreset = 1; */
+#endif
+ /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */
+
pargv = NULL;
/* Note: just "getopt() <= 0" will not work well for