nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH 08/10] assume getopt_long support is always availabl


From: Mike Frysinger
Subject: [Nano-devel] [PATCH 08/10] assume getopt_long support is always available
Date: Mon, 20 Feb 2017 13:42:14 -0500

Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
---
 autogen.sh   |  1 +
 configure.ac |  3 +--
 src/nano.c   | 30 ++----------------------------
 src/proto.h  |  6 +-----
 4 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index ccc5878faa7c..98ec7ed74427 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -7,6 +7,7 @@ gnulib_hash="730c5249cc17a4ebb7afcb3f2f4e73664eeff5ce"
 modules="
        getdelim
        getline
+       getopt-gnu
        isblank
        iswblank
        regex
diff --git a/configure.ac b/configure.ac
index c3c06567f74a..e2462c63705c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are 
placed to.])
 
 dnl Checks for header files.
 
-AC_CHECK_HEADERS(getopt.h libintl.h limits.h sys/param.h wchar.h wctype.h 
stdarg.h)
+AC_CHECK_HEADERS(libintl.h limits.h sys/param.h wchar.h wctype.h stdarg.h)
 
 dnl Checks for options.
 
@@ -499,7 +499,6 @@ dnl Checks for library functions.
 
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(getopt_long)
 
 dnl Checks for libraries.
 
diff --git a/src/nano.c b/src/nano.c
index 9f67f06d640a..fad54fb71283 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -35,9 +35,7 @@
 #include <langinfo.h>
 #endif
 #include <termios.h>
-#ifdef HAVE_GETOPT_H
 #include <getopt.h>
-#endif
 #ifndef NANO_TINY
 #include <sys/ioctl.h>
 #endif
@@ -742,32 +740,20 @@ void mouse_init(void)
 }
 #endif /* !DISABLE_MOUSE */
 
-#ifdef HAVE_GETOPT_LONG
-#define print_opt(shortflag, longflag, desc) print_opt_full(shortflag, 
longflag, desc)
-#else
-#define print_opt(shortflag, longflag, desc) print_opt_full(shortflag, desc)
-#endif
-
 /* Print one usage string to the screen.  This cuts down on duplicate
  * strings to translate, and leaves out the parts that shouldn't be
  * translatable (i.e. the flag names). */
-void print_opt_full(const char *shortflag
-#ifdef HAVE_GETOPT_LONG
-       , const char *longflag
-#endif
-       , const char *desc)
+void print_opt(const char *shortflag, const char *longflag, const char *desc)
 {
     printf(" %s\t", shortflag);
     if (strlenpt(shortflag) < 8)
        printf("\t");
 
-#ifdef HAVE_GETOPT_LONG
     printf("%s\t", longflag);
     if (strlenpt(longflag) < 8)
        printf("\t\t");
     else if (strlenpt(longflag) < 16)
        printf("\t");
-#endif
 
     if (desc != NULL)
        printf("%s", _(desc));
@@ -778,11 +764,7 @@ void print_opt_full(const char *shortflag
 void usage(void)
 {
     printf(_("Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...\n\n"));
-#ifdef HAVE_GETOPT_LONG
     printf(_("Option\t\tGNU long option\t\tMeaning\n"));
-#else
-    printf(_("Option\t\tMeaning\n"));
-#endif
     print_opt(_("+LINE,COLUMN"), "",
        /* TRANSLATORS: The next forty or so strings are option descriptions
         * for the --help output.  Try to keep them at most 40 characters. */
@@ -1920,7 +1902,6 @@ int main(int argc, char **argv)
        /* The old value of the multibuffer option, restored after we
         * load all files on the command line. */
 #endif
-#ifdef HAVE_GETOPT_LONG
     const struct option long_options[] = {
        {"boldtext", 0, NULL, 'D'},
 #ifndef DISABLE_MULTIBUFFER
@@ -1993,7 +1974,6 @@ int main(int argc, char **argv)
 #endif
        {NULL, 0, NULL, 0}
     };
-#endif
 
     /* Back up the terminal settings so that they can be restored. */
     tcgetattr(0, &oldterm);
@@ -2033,15 +2013,9 @@ int main(int argc, char **argv)
        SET(RESTRICTED);
 
     while ((optchr =
-#ifdef HAVE_GETOPT_LONG
        getopt_long(argc, argv,
                "ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
-               long_options, NULL)
-#else
-       getopt(argc, argv,
-               "ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$")
-#endif
-               ) != -1) {
+               long_options, NULL)) != -1) {
        switch (optchr) {
            case 'a':
            case 'b':
diff --git a/src/proto.h b/src/proto.h
index fd1f22d09d24..6ae9c942878c 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -425,11 +425,7 @@ void disable_mouse_support(void);
 void enable_mouse_support(void);
 void mouse_init(void);
 #endif
-void print_opt_full(const char *shortflag
-#ifdef HAVE_GETOPT_LONG
-       , const char *longflag
-#endif
-       , const char *desc);
+void print_opt(const char *shortflag, const char *longflag, const char *desc);
 void usage(void);
 void version(void);
 void do_exit(void);
-- 
2.11.1




reply via email to

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