| 687 | the above definition of `getopt'. */ |
| 688 | |
| 689 | int main (int argc, char **argv) |
| 690 | { |
| 691 | int c; |
| 692 | int digit_optind = 0; |
| 693 | |
| 694 | while (1) |
| 695 | { |
| 696 | int this_option_optind = optind ? optind : 1; |
| 697 | |
| 698 | c = fe_getopt (argc, argv, "abc:d:0123456789"); |
| 699 | if (c == EOF) |
| 700 | break; |
| 701 | |
| 702 | switch (c) |
| 703 | { |
| 704 | case '0': |
| 705 | case '1': |
| 706 | case '2': |
| 707 | case '3': |
| 708 | case '4': |
| 709 | case '5': |
| 710 | case '6': |
| 711 | case '7': |
| 712 | case '8': |
| 713 | case '9': |
| 714 | if (digit_optind != 0 && digit_optind != this_option_optind) |
| 715 | printf ("digits occur in two different argv-elements.\n"); |
| 716 | digit_optind = this_option_optind; |
| 717 | printf ("option %c\n", c); |
| 718 | break; |
| 719 | |
| 720 | case 'a': |
| 721 | printf ("option a\n"); |
| 722 | break; |
| 723 | |
| 724 | case 'b': |
| 725 | printf ("option b\n"); |
| 726 | break; |
| 727 | |
| 728 | case 'c': |
| 729 | printf ("option c with value `%s'\n", fe_optarg); |
| 730 | break; |
| 731 | |
| 732 | case BAD_OPTION: |
| 733 | break; |
| 734 | |
| 735 | default: |
| 736 | printf ("?? fe_getopt returned character code 0%o ??\n", c); |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | if (fe_optind < argc) |
| 741 | { |
| 742 | printf ("non-option ARGV-elements: "); |
| 743 | while (fe_optind < argc) |
| 744 | printf ("%s ", argv[fe_optind++]); |
| 745 | printf ("\n"); |
| 746 | } |
nothing calls this directly
no test coverage detected