aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-16 17:57:53 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-16 17:57:53 +0100
commitd46c36c74edc78242bacba1dc64576fe4e2e292a (patch)
tree38543b274743043962e54f4f603668d8f2889a2f
parent09b767250ddd874c47a0c9694079227707fd443e (diff)
downloadbusybox-w32-d46c36c74edc78242bacba1dc64576fe4e2e292a.tar.gz
busybox-w32-d46c36c74edc78242bacba1dc64576fe4e2e292a.tar.bz2
busybox-w32-d46c36c74edc78242bacba1dc64576fe4e2e292a.zip
libbb/getopt32.c: clear applet_long_options and opt_complementary after use
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/getopt32.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index cab3eb745..b5f83c127 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -423,6 +423,10 @@ getopt32(char **argv, const char *applet_opts, ...)
423 c++; 423 c++;
424 next_long: ; 424 next_long: ;
425 } 425 }
426 /* Make it unnecessary to clear applet_long_options
427 * by hand after each call to getopt32
428 */
429 applet_long_options = NULL;
426 } 430 }
427#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */ 431#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */
428 for (s = (const unsigned char *)opt_complementary; s && *s; s++) { 432 for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
@@ -485,15 +489,15 @@ getopt32(char **argv, const char *applet_opts, ...)
485 s++; 489 s++;
486 } 490 }
487 pair = on_off; 491 pair = on_off;
488 pair_switch = &(pair->switch_on); 492 pair_switch = &pair->switch_on;
489 for (s++; *s && *s != ':'; s++) { 493 for (s++; *s && *s != ':'; s++) {
490 if (*s == '?') { 494 if (*s == '?') {
491 pair_switch = &(pair->requires); 495 pair_switch = &pair->requires;
492 } else if (*s == '-') { 496 } else if (*s == '-') {
493 if (pair_switch == &(pair->switch_off)) 497 if (pair_switch == &pair->switch_off)
494 pair_switch = &(pair->incongruously); 498 pair_switch = &pair->incongruously;
495 else 499 else
496 pair_switch = &(pair->switch_off); 500 pair_switch = &pair->switch_off;
497 } else { 501 } else {
498 for (on_off = complementary; on_off->opt_char; on_off++) 502 for (on_off = complementary; on_off->opt_char; on_off++)
499 if (on_off->opt_char == *s) { 503 if (on_off->opt_char == *s) {
@@ -504,6 +508,7 @@ getopt32(char **argv, const char *applet_opts, ...)
504 } 508 }
505 s--; 509 s--;
506 } 510 }
511 opt_complementary = NULL;
507 va_end(p); 512 va_end(p);
508 513
509 if (spec_flgs & (FIRST_ARGV_IS_OPT | ALL_ARGV_IS_OPTS)) { 514 if (spec_flgs & (FIRST_ARGV_IS_OPT | ALL_ARGV_IS_OPTS)) {