diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-21 13:27:44 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-21 13:27:44 +0000 |
commit | 091965768da4175d3763e61db56bba058d68ae3b (patch) | |
tree | 011719c7b70c58099641d98244ea1aad9b2a8e5d /libbb | |
parent | 557fb713e0f943ac9b87c9f3804ba24e73d55bb0 (diff) | |
download | busybox-w32-091965768da4175d3763e61db56bba058d68ae3b.tar.gz busybox-w32-091965768da4175d3763e61db56bba058d68ae3b.tar.bz2 busybox-w32-091965768da4175d3763e61db56bba058d68ae3b.zip |
libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
find_pair 164 180 +16
passwd_main 1222 1230 +8
display_speed 91 96 +5
msh_main 1335 1339 +4
qrealloc 38 36 -2
refresh 1190 1182 -8
cut_main 543 532 -11
sendCgi 1807 1794 -13
getopt32 1063 1045 -18
arith 2077 2030 -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/6 up/down: 33/-99) Total: -66 bytes
text data bss dec hex filename
781548 1168 11900 794616 c1ff8 busybox_old
781452 1168 11900 794520 c1f98 busybox_unstripped
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/getopt32.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index d4465f899..f5aaa70df 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -217,20 +217,12 @@ Special characters: | |||
217 | -b, -c and -f are mutally exclusive and should raise an error | 217 | -b, -c and -f are mutally exclusive and should raise an error |
218 | if specified together. In this case you must set | 218 | if specified together. In this case you must set |
219 | opt_complementary = "b--cf:c--bf:f--bc". If two of the | 219 | opt_complementary = "b--cf:c--bf:f--bc". If two of the |
220 | mutually exclusive options are found, getopt32's | 220 | mutually exclusive options are found, getopt32 will call |
221 | return value will have the error flag set (BB_GETOPT_ERROR) so | 221 | bb_show_usage() and die. |
222 | that we can check for it: | ||
223 | |||
224 | if (flags & BB_GETOPT_ERROR) | ||
225 | bb_show_usage(); | ||
226 | 222 | ||
227 | "x--x" Variation of the above, it means that -x option should occur | 223 | "x--x" Variation of the above, it means that -x option should occur |
228 | at most once. | 224 | at most once. |
229 | 225 | ||
230 | "?" A "?" as the first char in a opt_complementary group means: | ||
231 | if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage | ||
232 | and exit instead. Next char after '?' can't be a digit. | ||
233 | |||
234 | "::" A double colon after a char in opt_complementary means that the | 226 | "::" A double colon after a char in opt_complementary means that the |
235 | option can occur multiple times. Each occurrence will be saved as | 227 | option can occur multiple times. Each occurrence will be saved as |
236 | a llist_t element instead of char*. | 228 | a llist_t element instead of char*. |
@@ -476,11 +468,8 @@ getopt32(int argc, char **argv, const char *applet_opts, ...) | |||
476 | if (on_off->opt == 0 && c != 0) | 468 | if (on_off->opt == 0 && c != 0) |
477 | bb_show_usage(); | 469 | bb_show_usage(); |
478 | } | 470 | } |
479 | if (flags & on_off->incongruously) { | 471 | if (flags & on_off->incongruously) |
480 | if ((spec_flgs & SHOW_USAGE_IF_ERROR)) | 472 | bb_show_usage(); |
481 | bb_show_usage(); | ||
482 | flags |= BB_GETOPT_ERROR; | ||
483 | } | ||
484 | trigger = on_off->switch_on & on_off->switch_off; | 473 | trigger = on_off->switch_on & on_off->switch_off; |
485 | flags &= ~(on_off->switch_off ^ trigger); | 474 | flags &= ~(on_off->switch_off ^ trigger); |
486 | flags |= on_off->switch_on ^ trigger; | 475 | flags |= on_off->switch_on ^ trigger; |