| 111 | #endif |
| 112 | |
| 113 | static void check_opt(const struct opt_table *entry) |
| 114 | { |
| 115 | const char *p; |
| 116 | unsigned len; |
| 117 | |
| 118 | if (entry->type != OPT_HASARG && entry->type != OPT_NOARG |
| 119 | && entry->type != (OPT_EARLY|OPT_HASARG) |
| 120 | && entry->type != (OPT_EARLY|OPT_NOARG)) |
| 121 | failmsg("Option %s: unknown entry type %u", |
| 122 | entry->names, entry->type); |
| 123 | |
| 124 | if (!entry->desc) |
| 125 | failmsg("Option %s: description cannot be NULL", entry->names); |
| 126 | |
| 127 | |
| 128 | if (entry->names[0] != '-') |
| 129 | failmsg("Option %s: does not begin with '-'", entry->names); |
| 130 | |
| 131 | for (p = first_name(entry->names, &len); p; p = next_name(p, &len)) { |
| 132 | if (*p == '-') { |
| 133 | if (len == 1) |
| 134 | failmsg("Option %s: invalid long option '--'", |
| 135 | entry->names); |
| 136 | opt_num_long++; |
| 137 | } else { |
| 138 | if (len != 1) |
| 139 | failmsg("Option %s: invalid short option" |
| 140 | " '%.*s'", entry->names, len+1, p-1); |
| 141 | opt_num_short++; |
| 142 | if (entry->type == OPT_HASARG) |
| 143 | opt_num_short_arg++; |
| 144 | } |
| 145 | /* Don't document args unless there are some. */ |
| 146 | if (entry->type == OPT_NOARG) { |
| 147 | if (p[len] == ' ' || p[len] == '=') |
| 148 | failmsg("Option %s: does not take arguments" |
| 149 | " '%s'", entry->names, p+len+1); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | static void add_opt(const struct opt_table *entry) |
| 155 | { |
no test coverage detected