emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ad063d2: emacsclient: getopt minor cleanup


From: Paul Eggert
Subject: [Emacs-diffs] master ad063d2: emacsclient: getopt minor cleanup
Date: Wed, 21 Nov 2018 21:38:25 -0500 (EST)

branch: master
commit ad063d2552d4d31fa668fa5f15a91aec18c010f6
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    emacsclient: getopt minor cleanup
    
    * lib-src/emacsclient.c (shortopts): New constant.
    (decode_options): Use it.  Do not assume EOF == -1.
---
 lib-src/emacsclient.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 908602e..4ab97c3 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -153,6 +153,7 @@ static char const *frame_parameters;
 
 static _Noreturn void print_help_and_exit (void);
 
+/* Long command-line options.  */
 
 static struct option const longopts[] =
 {
@@ -177,6 +178,15 @@ static struct option const longopts[] =
   { 0, 0, 0, 0 }
 };
 
+/* Short options, in the same order as the corresponding long options.
+   There is no '-p' short option.  */
+static char const shortopts[] =
+  "nqueHVtca:F:"
+#ifndef NO_SOCKETS_IN_FILE_SYSTEM
+  "s:"
+#endif
+  "f:d:T:";
+
 
 /* Like malloc but get fatal error if memory is exhausted.  */
 
@@ -485,15 +495,8 @@ decode_options (int argc, char **argv)
 
   while (true)
     {
-      int opt = getopt_long_only (argc, argv,
-#ifndef NO_SOCKETS_IN_FILE_SYSTEM
-                            "VHnequa:s:f:d:F:tcT:",
-#else
-                            "VHnequa:f:d:F:tcT:",
-#endif
-                            longopts, 0);
-
-      if (opt == EOF)
+      int opt = getopt_long_only (argc, argv, shortopts, longopts, NULL);
+      if (opt < 0)
        break;
 
       switch (opt)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]