(argc, argv)
| 85 | #include <stdio.h> |
| 86 | |
| 87 | int |
| 88 | main(argc, argv) |
| 89 | int argc; |
| 90 | char **argv; |
| 91 | { |
| 92 | while (1) |
| 93 | { |
| 94 | int c; |
| 95 | int digit_optind = 0; |
| 96 | |
| 97 | int this_option_optind = optind ? optind : 1; |
| 98 | int option_index = 0; |
| 99 | static struct option long_options[] = |
| 100 | { |
| 101 | {"add", 1, 0, 0}, |
| 102 | {"append", 0, 0, 0}, |
| 103 | {"delete", 1, 0, 0}, |
| 104 | {"verbose", 0, 0, 0}, |
| 105 | {"create", 0, 0, 0}, |
| 106 | {"file", 1, 0, 0}, |
| 107 | {0, 0, 0, 0} |
| 108 | }; |
| 109 | |
| 110 | c = getopt_long(argc, argv, "abc:d:0123456789", |
| 111 | long_options, &option_index); |
| 112 | |
| 113 | if (c == EOF) |
| 114 | { |
| 115 | break; |
| 116 | } |
| 117 | |
| 118 | switch (c) |
| 119 | { |
| 120 | case 0: |
| 121 | printf("option %s", long_options[option_index].name); |
| 122 | |
| 123 | if (optarg) |
| 124 | { |
| 125 | printf(" with arg %s", optarg); |
| 126 | } |
| 127 | |
| 128 | printf("\n"); |
| 129 | break; |
| 130 | |
| 131 | case '0': |
| 132 | case '1': |
| 133 | case '2': |
| 134 | case '3': |
| 135 | case '4': |
| 136 | case '5': |
| 137 | case '6': |
| 138 | case '7': |
| 139 | case '8': |
| 140 | case '9': |
| 141 | if (digit_optind != 0 && digit_optind != this_option_optind) |
| 142 | { |
| 143 | printf("digits occur in two different argv-elements.\n"); |
| 144 | } |
nothing calls this directly
no test coverage detected