[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, 18 Apr 2016 02:17:43 -0400 |
Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
---
autogen.sh | 1 +
configure.ac | 3 +--
src/nano.c | 34 +++-------------------------------
src/proto.h | 6 +-----
4 files changed, 6 insertions(+), 38 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index ccc5878..98ec7ed 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 cb6473f..3d837ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,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.
@@ -458,7 +458,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 e6b3481..0037bf5 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -34,9 +34,7 @@
#include <langinfo.h>
#endif
#include <termios.h>
-#ifdef HAVE_GETOPT_H
#include <getopt.h>
-#endif
#ifndef NANO_TINY
#include <sys/ioctl.h>
#endif
@@ -768,32 +766,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));
@@ -804,13 +790,7 @@ void print_opt_full(const char *shortflag
void usage(void)
{
printf(_("Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...\n\n"));
- printf(
-#ifdef HAVE_GETOPT_LONG
- _("Option\t\tGNU long option\t\tMeaning\n")
-#else
- _("Option\t\tMeaning\n")
-#endif
- );
+ printf(_("Option\t\tGNU long option\t\tMeaning\n"));
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. */
@@ -1947,7 +1927,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
@@ -2013,7 +1992,6 @@ int main(int argc, char **argv)
#endif
{NULL, 0, NULL, 0}
};
-#endif
#ifdef ENABLE_UTF8
{
@@ -2046,15 +2024,9 @@ int main(int argc, char **argv)
#endif
while ((optchr =
-#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
- long_options, NULL)
-#else
- getopt(argc, argv,
- "ABC:DEFGHIKLNOPQ:RST:UVWY: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 7f4a9b5..deffbde 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -441,11 +441,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);
int more_space(void);
--
2.7.4
- Re: [Nano-devel] [PATCH 01/10] configure: require autoconf-2.69/automake-1.14, (continued)
[Nano-devel] [PATCH 05/10] drop getdelim/getline fallback functions, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 09/10] drop glib fallback for snprintf/vsnprintf, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 06/10] drop isblank/iswblank fallback functions, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 10/10] drop wchar.h/wctype.h/stdarg.h checks, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 08/10] assume getopt_long support is always available,
Mike Frysinger <=
[Nano-devel] [PATCH 04/10] drop various str fallback functions, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 03/10] add support for gnulib, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 02/10] gettext: update to 0.18.3 release, Mike Frysinger, 2016/04/18
[Nano-devel] [PATCH 07/10] assume regex.h support is always available, Mike Frysinger, 2016/04/18
Re: [Nano-devel] [PATCH 00/10] update autotools & add gnulib support, Kamil Dudka, 2016/04/18