diff options
Diffstat (limited to '')
-rw-r--r-- | libbb/getopt32.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index b5efa19ac..9247588d9 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -530,6 +530,7 @@ vgetopt32(char **argv, const char *applet_opts, const char *applet_long_options, | |||
530 | * "fake" short options, like this one: | 530 | * "fake" short options, like this one: |
531 | * wget $'-\203' "Test: test" http://kernel.org/ | 531 | * wget $'-\203' "Test: test" http://kernel.org/ |
532 | * (supposed to act as --header, but doesn't) */ | 532 | * (supposed to act as --header, but doesn't) */ |
533 | next_opt: | ||
533 | #if ENABLE_LONG_OPTS | 534 | #if ENABLE_LONG_OPTS |
534 | while ((c = getopt_long(argc, argv, applet_opts, | 535 | while ((c = getopt_long(argc, argv, applet_opts, |
535 | long_options, NULL)) != -1) { | 536 | long_options, NULL)) != -1) { |
@@ -544,8 +545,16 @@ vgetopt32(char **argv, const char *applet_opts, const char *applet_long_options, | |||
544 | * but we construct long opts so that flag | 545 | * but we construct long opts so that flag |
545 | * is always NULL (see above) */ | 546 | * is always NULL (see above) */ |
546 | if (on_off->opt_char == '\0' /* && c != '\0' */) { | 547 | if (on_off->opt_char == '\0' /* && c != '\0' */) { |
547 | /* c is probably '?' - "bad option" */ | 548 | /* We reached the end of complementary[] and did not find -c */ |
548 | goto error; | 549 | if (c == '?') /* getopt says: "bad option, or option has no required argument" */ |
550 | goto error; | ||
551 | /* if there were options beyond 32 bits (example: ls), | ||
552 | * they got no complementary[] slot, and no result bit. | ||
553 | * IOW: they must be "accept but ignore" options. | ||
554 | * For them, we end up here. | ||
555 | */ | ||
556 | //bb_error_msg("ignored option '%c', skipping", c); | ||
557 | goto next_opt; | ||
549 | } | 558 | } |
550 | } | 559 | } |
551 | if (flags & on_off->incongruously) | 560 | if (flags & on_off->incongruously) |
@@ -592,7 +601,7 @@ vgetopt32(char **argv, const char *applet_opts, const char *applet_long_options, | |||
592 | return (int32_t)-1; | 601 | return (int32_t)-1; |
593 | } | 602 | } |
594 | 603 | ||
595 | uint32_t FAST_FUNC | 604 | uint32_t |
596 | getopt32(char **argv, const char *applet_opts, ...) | 605 | getopt32(char **argv, const char *applet_opts, ...) |
597 | { | 606 | { |
598 | uint32_t opt; | 607 | uint32_t opt; |
@@ -605,7 +614,7 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
605 | } | 614 | } |
606 | 615 | ||
607 | #if ENABLE_LONG_OPTS | 616 | #if ENABLE_LONG_OPTS |
608 | uint32_t FAST_FUNC | 617 | uint32_t |
609 | getopt32long(char **argv, const char *applet_opts, const char *longopts, ...) | 618 | getopt32long(char **argv, const char *applet_opts, const char *longopts, ...) |
610 | { | 619 | { |
611 | uint32_t opt; | 620 | uint32_t opt; |