| 613 | } |
| 614 | |
| 615 | static const char * findNextArg(poptContext con, |
| 616 | unsigned argx, int delete_arg) |
| 617 | { |
| 618 | struct optionStackEntry * os = con->os; |
| 619 | const char * arg; |
| 620 | |
| 621 | do { |
| 622 | int i; |
| 623 | arg = NULL; |
| 624 | while (os->next == os->argc && os > con->optionStack) os--; |
| 625 | if (os->next == os->argc && os == con->optionStack) break; |
| 626 | if (os->argv != NULL) |
| 627 | for (i = os->next; i < os->argc; i++) { |
| 628 | if (os->argb && PBM_ISSET(i, os->argb)) |
| 629 | continue; |
| 630 | if (*os->argv[i] == '-') |
| 631 | continue; |
| 632 | if (--argx > 0) |
| 633 | continue; |
| 634 | arg = os->argv[i]; |
| 635 | if (delete_arg) { |
| 636 | if (os->argb == NULL) os->argb = PBM_ALLOC(os->argc); |
| 637 | if (os->argb != NULL) /* XXX can't happen */ |
| 638 | PBM_SET(i, os->argb); |
| 639 | } |
| 640 | break; |
| 641 | } |
| 642 | if (os > con->optionStack) os--; |
| 643 | } while (arg == NULL); |
| 644 | return arg; |
| 645 | } |
| 646 | |
| 647 | static const char * |
| 648 | expandNextArg(poptContext con, const char * s) |