mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-30 22:24:41 +03:00
assume getopt_long support is always available
Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
This commit is contained in:
parent
3deec4352b
commit
272345ccf9
@ -7,6 +7,7 @@ gnulib_hash="4084b3a1094372b960ce4a97634e08f4538c8bdd"
|
|||||||
modules="
|
modules="
|
||||||
getdelim
|
getdelim
|
||||||
getline
|
getline
|
||||||
|
getopt-gnu
|
||||||
isblank
|
isblank
|
||||||
iswblank
|
iswblank
|
||||||
regex
|
regex
|
||||||
|
@ -54,7 +54,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
|||||||
|
|
||||||
dnl Checks for header files.
|
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.
|
dnl Checks for options.
|
||||||
|
|
||||||
@ -499,7 +499,6 @@ dnl Checks for library functions.
|
|||||||
|
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_CHECK_FUNCS(getopt_long)
|
|
||||||
|
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
|
|
||||||
|
30
src/nano.c
30
src/nano.c
@ -35,9 +35,7 @@
|
|||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#endif
|
#endif
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#endif
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
@ -746,32 +744,20 @@ void mouse_init(void)
|
|||||||
}
|
}
|
||||||
#endif /* !DISABLE_MOUSE */
|
#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
|
/* Print one usage string to the screen. This cuts down on duplicate
|
||||||
* strings to translate, and leaves out the parts that shouldn't be
|
* strings to translate, and leaves out the parts that shouldn't be
|
||||||
* translatable (i.e. the flag names). */
|
* translatable (i.e. the flag names). */
|
||||||
void print_opt_full(const char *shortflag
|
void print_opt(const char *shortflag, const char *longflag, const char *desc)
|
||||||
#ifdef HAVE_GETOPT_LONG
|
|
||||||
, const char *longflag
|
|
||||||
#endif
|
|
||||||
, const char *desc)
|
|
||||||
{
|
{
|
||||||
printf(" %s\t", shortflag);
|
printf(" %s\t", shortflag);
|
||||||
if (strlenpt(shortflag) < 8)
|
if (strlenpt(shortflag) < 8)
|
||||||
printf("\t");
|
printf("\t");
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
|
||||||
printf("%s\t", longflag);
|
printf("%s\t", longflag);
|
||||||
if (strlenpt(longflag) < 8)
|
if (strlenpt(longflag) < 8)
|
||||||
printf("\t\t");
|
printf("\t\t");
|
||||||
else if (strlenpt(longflag) < 16)
|
else if (strlenpt(longflag) < 16)
|
||||||
printf("\t");
|
printf("\t");
|
||||||
#endif
|
|
||||||
|
|
||||||
if (desc != NULL)
|
if (desc != NULL)
|
||||||
printf("%s", _(desc));
|
printf("%s", _(desc));
|
||||||
@ -787,11 +773,7 @@ void usage(void)
|
|||||||
printf(_("To place the cursor on a specific line of a file, put the line number with\n"
|
printf(_("To place the cursor on a specific line of a file, put the line number with\n"
|
||||||
"a '+' before the filename. The column number can be added after a comma.\n"));
|
"a '+' before the filename. The column number can be added after a comma.\n"));
|
||||||
printf(_("When the first filename is '-', nano reads data from standard input.\n\n"));
|
printf(_("When the first filename is '-', nano reads data from standard input.\n\n"));
|
||||||
#ifdef HAVE_GETOPT_LONG
|
|
||||||
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
|
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
|
||||||
#else
|
|
||||||
printf(_("Option\t\tMeaning\n"));
|
|
||||||
#endif
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
print_opt("-A", "--smarthome",
|
print_opt("-A", "--smarthome",
|
||||||
/* TRANSLATORS: The next forty or so strings are option descriptions
|
/* TRANSLATORS: The next forty or so strings are option descriptions
|
||||||
@ -1925,7 +1907,6 @@ int main(int argc, char **argv)
|
|||||||
/* The old value of the multibuffer option, restored after we
|
/* The old value of the multibuffer option, restored after we
|
||||||
* load all files on the command line. */
|
* load all files on the command line. */
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETOPT_LONG
|
|
||||||
const struct option long_options[] = {
|
const struct option long_options[] = {
|
||||||
{"boldtext", 0, NULL, 'D'},
|
{"boldtext", 0, NULL, 'D'},
|
||||||
#ifndef DISABLE_MULTIBUFFER
|
#ifndef DISABLE_MULTIBUFFER
|
||||||
@ -1998,7 +1979,6 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Back up the terminal settings so that they can be restored. */
|
/* Back up the terminal settings so that they can be restored. */
|
||||||
tcgetattr(0, &oldterm);
|
tcgetattr(0, &oldterm);
|
||||||
@ -2038,15 +2018,9 @@ int main(int argc, char **argv)
|
|||||||
SET(RESTRICTED);
|
SET(RESTRICTED);
|
||||||
|
|
||||||
while ((optchr =
|
while ((optchr =
|
||||||
#ifdef HAVE_GETOPT_LONG
|
|
||||||
getopt_long(argc, argv,
|
getopt_long(argc, argv,
|
||||||
"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
|
"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
|
||||||
long_options, NULL)
|
long_options, NULL)) != -1) {
|
||||||
#else
|
|
||||||
getopt(argc, argv,
|
|
||||||
"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$")
|
|
||||||
#endif
|
|
||||||
) != -1) {
|
|
||||||
switch (optchr) {
|
switch (optchr) {
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -431,11 +431,7 @@ void disable_mouse_support(void);
|
|||||||
void enable_mouse_support(void);
|
void enable_mouse_support(void);
|
||||||
void mouse_init(void);
|
void mouse_init(void);
|
||||||
#endif
|
#endif
|
||||||
void print_opt_full(const char *shortflag
|
void print_opt(const char *shortflag, const char *longflag, const char *desc);
|
||||||
#ifdef HAVE_GETOPT_LONG
|
|
||||||
, const char *longflag
|
|
||||||
#endif
|
|
||||||
, const char *desc);
|
|
||||||
void usage(void);
|
void usage(void);
|
||||||
void version(void);
|
void version(void);
|
||||||
void do_exit(void);
|
void do_exit(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user