diff options
| author | Paul Eggert | 2018-11-21 18:37:44 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-11-21 18:38:20 -0800 |
| commit | ad063d2552d4d31fa668fa5f15a91aec18c010f6 (patch) | |
| tree | 6d1ca54e87f89e28c55894e98af26a3ec493b391 /lib-src | |
| parent | 0f22bf099e569790fe6bb830522b5e41be41bbb6 (diff) | |
| download | emacs-ad063d2552d4d31fa668fa5f15a91aec18c010f6.tar.gz emacs-ad063d2552d4d31fa668fa5f15a91aec18c010f6.zip | |
emacsclient: getopt minor cleanup
* lib-src/emacsclient.c (shortopts): New constant.
(decode_options): Use it. Do not assume EOF == -1.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 908602ec254..4ab97c3c50c 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -153,6 +153,7 @@ static char const *frame_parameters; | |||
| 153 | 153 | ||
| 154 | static _Noreturn void print_help_and_exit (void); | 154 | static _Noreturn void print_help_and_exit (void); |
| 155 | 155 | ||
| 156 | /* Long command-line options. */ | ||
| 156 | 157 | ||
| 157 | static struct option const longopts[] = | 158 | static struct option const longopts[] = |
| 158 | { | 159 | { |
| @@ -177,6 +178,15 @@ static struct option const longopts[] = | |||
| 177 | { 0, 0, 0, 0 } | 178 | { 0, 0, 0, 0 } |
| 178 | }; | 179 | }; |
| 179 | 180 | ||
| 181 | /* Short options, in the same order as the corresponding long options. | ||
| 182 | There is no '-p' short option. */ | ||
| 183 | static char const shortopts[] = | ||
| 184 | "nqueHVtca:F:" | ||
| 185 | #ifndef NO_SOCKETS_IN_FILE_SYSTEM | ||
| 186 | "s:" | ||
| 187 | #endif | ||
| 188 | "f:d:T:"; | ||
| 189 | |||
| 180 | 190 | ||
| 181 | /* Like malloc but get fatal error if memory is exhausted. */ | 191 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 182 | 192 | ||
| @@ -485,15 +495,8 @@ decode_options (int argc, char **argv) | |||
| 485 | 495 | ||
| 486 | while (true) | 496 | while (true) |
| 487 | { | 497 | { |
| 488 | int opt = getopt_long_only (argc, argv, | 498 | int opt = getopt_long_only (argc, argv, shortopts, longopts, NULL); |
| 489 | #ifndef NO_SOCKETS_IN_FILE_SYSTEM | 499 | if (opt < 0) |
| 490 | "VHnequa:s:f:d:F:tcT:", | ||
| 491 | #else | ||
| 492 | "VHnequa:f:d:F:tcT:", | ||
| 493 | #endif | ||
| 494 | longopts, 0); | ||
| 495 | |||
| 496 | if (opt == EOF) | ||
| 497 | break; | 500 | break; |
| 498 | 501 | ||
| 499 | switch (opt) | 502 | switch (opt) |