| 424 | } |
| 425 | |
| 426 | static enum parse_opt_result parse_short_opt(struct parse_opt_ctx_t *p, |
| 427 | const struct option *options) |
| 428 | { |
| 429 | const struct option *numopt = NULL; |
| 430 | |
| 431 | for (; options->type != OPTION_END; options++) { |
| 432 | if (options->short_name == *p->opt) { |
| 433 | p->opt = p->opt[1] ? p->opt + 1 : NULL; |
| 434 | return get_value(p, options, OPT_SHORT); |
| 435 | } |
| 436 | |
| 437 | /* |
| 438 | * Handle the numerical option later, explicit one-digit |
| 439 | * options take precedence over it. |
| 440 | */ |
| 441 | if (options->type == OPTION_NUMBER) |
| 442 | numopt = options; |
| 443 | } |
| 444 | if (numopt && isdigit(*p->opt)) { |
| 445 | size_t len = 1; |
| 446 | char *arg; |
| 447 | int rc; |
| 448 | |
| 449 | while (isdigit(p->opt[len])) |
| 450 | len++; |
| 451 | arg = xmemdupz(p->opt, len); |
| 452 | p->opt = p->opt[len] ? p->opt + len : NULL; |
| 453 | if (numopt->callback) |
| 454 | rc = (*numopt->callback)(numopt, arg, 0) ? (-1) : 0; |
| 455 | else |
| 456 | rc = (*numopt->ll_callback)(p, numopt, arg, 0); |
| 457 | free(arg); |
| 458 | return rc; |
| 459 | } |
| 460 | return PARSE_OPT_UNKNOWN; |
| 461 | } |
| 462 | |
| 463 | static int has_string(const char *it, const char **array) |
| 464 | { |
no test coverage detected