mirror of
https://github.com/sheumann/hush.git
synced 2025-02-22 10:29:10 +00:00
libbb/getopt32.c: clear applet_long_options and opt_complementary after use
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
09b767250d
commit
d46c36c74e
@ -423,6 +423,10 @@ getopt32(char **argv, const char *applet_opts, ...)
|
|||||||
c++;
|
c++;
|
||||||
next_long: ;
|
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 */
|
#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */
|
||||||
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
|
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
|
||||||
@ -485,15 +489,15 @@ getopt32(char **argv, const char *applet_opts, ...)
|
|||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
pair = on_off;
|
pair = on_off;
|
||||||
pair_switch = &(pair->switch_on);
|
pair_switch = &pair->switch_on;
|
||||||
for (s++; *s && *s != ':'; s++) {
|
for (s++; *s && *s != ':'; s++) {
|
||||||
if (*s == '?') {
|
if (*s == '?') {
|
||||||
pair_switch = &(pair->requires);
|
pair_switch = &pair->requires;
|
||||||
} else if (*s == '-') {
|
} else if (*s == '-') {
|
||||||
if (pair_switch == &(pair->switch_off))
|
if (pair_switch == &pair->switch_off)
|
||||||
pair_switch = &(pair->incongruously);
|
pair_switch = &pair->incongruously;
|
||||||
else
|
else
|
||||||
pair_switch = &(pair->switch_off);
|
pair_switch = &pair->switch_off;
|
||||||
} else {
|
} else {
|
||||||
for (on_off = complementary; on_off->opt_char; on_off++)
|
for (on_off = complementary; on_off->opt_char; on_off++)
|
||||||
if (on_off->opt_char == *s) {
|
if (on_off->opt_char == *s) {
|
||||||
@ -504,6 +508,7 @@ getopt32(char **argv, const char *applet_opts, ...)
|
|||||||
}
|
}
|
||||||
s--;
|
s--;
|
||||||
}
|
}
|
||||||
|
opt_complementary = NULL;
|
||||||
va_end(p);
|
va_end(p);
|
||||||
|
|
||||||
if (spec_flgs & (FIRST_ARGV_IS_OPT | ALL_ARGV_IS_OPTS)) {
|
if (spec_flgs & (FIRST_ARGV_IS_OPT | ALL_ARGV_IS_OPTS)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user