summaryrefslogtreecommitdiff
path: root/libbb/getopt32.c
diff options
context:
space:
mode:
authorDenys Vlasenko2010-03-16 17:57:53 +0100
committerDenys Vlasenko2010-03-16 17:57:53 +0100
commitd46c36c74edc78242bacba1dc64576fe4e2e292a (patch)
tree38543b274743043962e54f4f603668d8f2889a2f /libbb/getopt32.c
parent09b767250ddd874c47a0c9694079227707fd443e (diff)
downloadbusybox-d46c36c74edc78242bacba1dc64576fe4e2e292a.zip
busybox-d46c36c74edc78242bacba1dc64576fe4e2e292a.tar.gz
libbb/getopt32.c: clear applet_long_options and opt_complementary after use
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/getopt32.c')
-rw-r--r--libbb/getopt32.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index cab3eb7..b5f83c1 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -423,6 +423,10 @@ getopt32(char **argv, const char *applet_opts, ...)
c++;
next_long: ;
}
+ /* Make it unnecessary to clear applet_long_options
+ * by hand after each call to getopt32
+ */
+ applet_long_options = NULL;
}
#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
@@ -485,15 +489,15 @@ getopt32(char **argv, const char *applet_opts, ...)
s++;
}
pair = on_off;
- pair_switch = &(pair->switch_on);
+ pair_switch = &pair->switch_on;
for (s++; *s && *s != ':'; s++) {
if (*s == '?') {
- pair_switch = &(pair->requires);
+ pair_switch = &pair->requires;
} else if (*s == '-') {
- if (pair_switch == &(pair->switch_off))
- pair_switch = &(pair->incongruously);
+ if (pair_switch == &pair->switch_off)
+ pair_switch = &pair->incongruously;
else
- pair_switch = &(pair->switch_off);
+ pair_switch = &pair->switch_off;
} else {
for (on_off = complementary; on_off->opt_char; on_off++)
if (on_off->opt_char == *s) {
@@ -504,6 +508,7 @@ getopt32(char **argv, const char *applet_opts, ...)
}
s--;
}
+ opt_complementary = NULL;
va_end(p);
if (spec_flgs & (FIRST_ARGV_IS_OPT | ALL_ARGV_IS_OPTS)) {