Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/libbb/getopt32.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/libbb/getopt32.c
r2725 r3232 8 8 */ 9 9 10 #include <getopt.h> 10 #if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG 11 # include <getopt.h> 12 #endif 11 13 #include "libbb.h" 12 14 … … 81 83 82 84 static const char applet_longopts[] ALIGN1 = 83 84 85 85 //"name\0" has_arg val 86 "verbose\0" No_argument "v" 87 ; 86 88 applet_long_options = applet_longopts; 87 89 … … 227 229 opt_complementary = "b--cf:c--bf:f--bc". If two of the 228 230 mutually exclusive options are found, getopt32 will call 229 231 bb_show_usage() and die. 230 232 231 233 "x--x" Variation of the above, it means that -x option should occur … … 466 468 for (on_off = complementary; on_off->opt_char; on_off++) 467 469 if (on_off->opt_char == *s) 468 break; 470 goto found_opt; 471 /* Without this, diagnostic of such bugs is not easy */ 472 bb_error_msg_and_die("NO OPT %c!", *s); 473 found_opt: 469 474 if (c == ':' && s[2] == ':') { 470 475 on_off->param_type = PARAM_LIST; … … 473 478 if (c == '+' && (s[2] == ':' || s[2] == '\0')) { 474 479 on_off->param_type = PARAM_INT; 480 s++; 475 481 continue; 476 482 } … … 532 538 /* In case getopt32 was already called: 533 539 * reset the libc getopt() function, which keeps internal state. 534 * run_nofork_applet _prime() does this, but we might end up here540 * run_nofork_applet() does this, but we might end up here 535 541 * also via gunzip_main() -> gzip_main(). Play safe. 536 542 */ … … 542 548 #endif 543 549 /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ 544 545 pargv = NULL;546 550 547 551 /* Note: just "getopt() <= 0" will not work well for … … 575 579 if (on_off->counter) 576 580 (*(on_off->counter))++; 577 if (o n_off->param_type == PARAM_LIST) {578 if (o ptarg)581 if (optarg) { 582 if (on_off->param_type == PARAM_LIST) { 579 583 llist_add_to_end((llist_t **)(on_off->optarg), optarg); 580 } else if (on_off->param_type == PARAM_INT) { 581 if (optarg) 584 } else if (on_off->param_type == PARAM_INT) { 582 585 //TODO: xatoi_positive indirectly pulls in printf machinery 583 586 *(unsigned*)(on_off->optarg) = xatoi_positive(optarg); 584 } else if (on_off->optarg) { 585 if (optarg) 587 } else if (on_off->optarg) { 586 588 *(char **)(on_off->optarg) = optarg; 587 } 588 if (pargv != NULL) 589 break; 589 } 590 } 590 591 } 591 592
Note:
See TracChangeset
for help on using the changeset viewer.