mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
scanner: simplify the getopt logic
Use the same retvals for both short and long options. Whitespace fixes. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
8877a349e7
commit
d08c079739
1 changed files with 14 additions and 30 deletions
|
|
@ -1302,7 +1302,7 @@ int main(int argc, char *argv[])
|
||||||
void *buf;
|
void *buf;
|
||||||
bool help = false, core_headers = false;
|
bool help = false, core_headers = false;
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
int opt, option_index = 0;
|
int opt;
|
||||||
enum {
|
enum {
|
||||||
CLIENT_HEADER,
|
CLIENT_HEADER,
|
||||||
SERVER_HEADER,
|
SERVER_HEADER,
|
||||||
|
|
@ -1310,43 +1310,27 @@ int main(int argc, char *argv[])
|
||||||
} mode;
|
} mode;
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
{"help", no_argument, 0, 0 },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{"include-core-only", no_argument, 0, 0 },
|
{ "include-core-only", no_argument, NULL, 'c' },
|
||||||
{0, 0, 0, 0 }
|
{ 0, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
opt = getopt_long(argc, argv, "hc",
|
opt = getopt_long(argc, argv, "hc", options, NULL);
|
||||||
options, &option_index);
|
|
||||||
|
|
||||||
if (opt == -1)
|
if (opt == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (opt == 0) {
|
|
||||||
switch (option_index) {
|
|
||||||
case 0:
|
|
||||||
help = true;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
core_headers = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fail = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
help = true;
|
help = true;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
core_headers = true;
|
core_headers = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fail = true;
|
fail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue