tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC

Also, allow rebinding the word and block jumping functions
in the tiny version when nanorc files are reenabled.
master
Benno Schulenberg 2017-05-08 19:42:44 +02:00
parent a05180ed2d
commit 858e75e4cf
7 changed files with 52 additions and 48 deletions

View File

@ -193,10 +193,17 @@ fi
AC_ARG_ENABLE(nanorc,
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
if test "x$enable_nanorc" = xno; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
else
nanorc_support=yes
if test "x$enable_tiny" = xyes; then
if test "x$enable_nanorc" != xyes; then
enable_nanorc=no
fi
fi
if test "x$disable_nanorc" != xyes; then
if test "x$enable_nanorc" != xno; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to enable the use of .nanorc files.])
else
nanorc_support=yes
fi
fi
AC_ARG_ENABLE(operatingdir,
@ -283,9 +290,6 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_libmagic" != xyes; then
enable_libmagic=no
fi
if test "x$enable_nanorc" != xyes; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
fi
if test "x$enable_operatingdir" != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi

View File

@ -686,7 +686,7 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
}
#endif /* !NANO_TINY */
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
/* Return TRUE if the string s contains one or more blank characters,
* and FALSE otherwise. */
bool has_blank_chars(const char *s)
@ -719,7 +719,7 @@ bool has_blank_mbchars(const char *s)
#endif
return has_blank_chars(s);
}
#endif /* !DISABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#endif /* ENABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
@ -732,7 +732,7 @@ bool is_valid_unicode(wchar_t wc)
}
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
@ -744,4 +744,4 @@ bool is_valid_mbstring(const char *s)
#endif
return TRUE;
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */

View File

@ -1408,7 +1408,7 @@ const char *flagtostr(int flag)
}
#endif /* !NANO_TINY */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Interpret a function string given in the rc file, and return a
* shortcut struct with the corresponding function filled in. */
sc *strtosc(const char *input)
@ -1504,18 +1504,10 @@ sc *strtosc(const char *input)
s->scfunc = do_scroll_up;
else if (!strcasecmp(input, "scrolldown"))
s->scfunc = do_scroll_down;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
else if (!strcasecmp(input, "cutwordleft"))
s->scfunc = do_cut_prev_word;
else if (!strcasecmp(input, "cutwordright"))
s->scfunc = do_cut_next_word;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
else if (!strcasecmp(input, "findbracket"))
s->scfunc = do_find_bracket;
else if (!strcasecmp(input, "wordcount"))
@ -1537,10 +1529,18 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "down") ||
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home_void;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end_void;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
@ -1717,7 +1717,7 @@ int strtomenu(const char *input)
#endif
return -1;
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#ifdef DEBUG
@ -1823,7 +1823,7 @@ void thanks_for_all_the_fish(void)
sclist = sclist->next;
free(s);
}
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
free(homedir);
#endif
}

View File

@ -45,7 +45,7 @@
static int oldinterval = -1;
/* Used to store the user's original mouse click interval. */
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
static bool no_rcfiles = FALSE;
/* Should we ignore all rcfiles? */
#endif
@ -804,7 +804,7 @@ void usage(void)
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
if (!ISSET(RESTRICTED))
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif
@ -869,7 +869,7 @@ void usage(void)
N_("Set operating directory"));
#endif
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
if (!ISSET(RESTRICTED))
print_opt("-q", "--quiet",
N_("Silently ignore startup issues like rc file errors"));
@ -943,7 +943,7 @@ void version(void)
#ifdef ENABLE_MOUSE
printf(" --enable-mouse");
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
printf(" --enable-nanorc");
#endif
#ifdef ENABLE_MULTIBUFFER
@ -995,7 +995,7 @@ void version(void)
#ifndef ENABLE_MULTIBUFFER
printf(" --disable-multibuffer");
#endif
#ifdef DISABLE_NANORC
#ifndef ENABLE_NANORC
printf(" --disable-nanorc");
#endif
#ifdef DISABLE_OPERATINGDIR
@ -1917,7 +1917,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", 0, NULL, 'F'},
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
{"ignorercfiles", 0, NULL, 'I'},
#endif
{"rebindkeypad", 0, NULL, 'K'},
@ -2013,7 +2013,7 @@ int main(int argc, char **argv)
" -- please report a bug\n", (int)MB_CUR_MAX);
#endif
#if defined(DISABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
#if !defined(ENABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
/* If we don't have rcfile support, --disable-wrapping-as-root is
* used, and we're root, turn wrapping off. */
if (geteuid() == NANO_ROOT_UID)
@ -2070,7 +2070,7 @@ int main(int argc, char **argv)
SET(HISTORYLOG);
break;
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
case 'I':
no_rcfiles = TRUE;
break;
@ -2166,7 +2166,7 @@ int main(int argc, char **argv)
case 'p':
SET(PRESERVE);
break;
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
case 'q':
SET(QUIET);
break;
@ -2239,7 +2239,7 @@ int main(int argc, char **argv)
if (ISSET(RESTRICTED)) {
UNSET(SUSPEND);
UNSET(BACKUP_FILE);
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
no_rcfiles = TRUE;
UNSET(HISTORYLOG);
UNSET(POS_HISTORY);
@ -2250,11 +2250,9 @@ int main(int argc, char **argv)
* before reading the rcfile, to be able to rebind/unbind keys. */
shortcut_init();
/* We've read through the command line options. Now back up the flags
* and values that are set, and read the rcfile(s). If the values
* haven't changed afterward, restore the backed-up values. */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
if (!no_rcfiles) {
/* Back up the command-line options, then read the rcfile(s). */
#ifndef DISABLE_OPERATINGDIR
char *operating_dir_cpy = operating_dir;
#endif
@ -2298,6 +2296,7 @@ int main(int argc, char **argv)
print_sclist();
#endif
/* If the backed-up command-line options have a value, restore them. */
#ifndef DISABLE_OPERATINGDIR
if (operating_dir_cpy != NULL) {
free(operating_dir);
@ -2333,6 +2332,7 @@ int main(int argc, char **argv)
if (tabsize_cpy != -1)
tabsize = tabsize_cpy;
/* Simply OR the boolean flags from rcfile and command line. */
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
flags[i] |= flags_cpy[i];
}
@ -2342,7 +2342,7 @@ int main(int argc, char **argv)
else if (geteuid() == NANO_ROOT_UID)
SET(NO_WRAP);
#endif
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#ifndef DISABLE_WRAPPING
/* Override a "set nowrap" in an rcfile (or a --disable-wrapping-as-root)

View File

@ -404,7 +404,7 @@ typedef struct openfilestruct {
/* The preceding open file, if any. */
} openfilestruct;
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
typedef struct rcoption {
const char *name;
/* The name of the rcfile option. */

View File

@ -225,13 +225,13 @@ char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
#endif
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_mbchars(const char *s);
#endif
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
@ -466,14 +466,14 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
#ifndef DISABLE_COLOR
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif
void parse_rcfile(FILE *rcstream, bool syntax_only);
void do_rcfiles(void);
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
/* Most functions in search.c. */
void not_found_msg(const char *str);

View File

@ -30,7 +30,7 @@
#include <unistd.h>
#include <ctype.h>
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
#ifndef RCFILE_NAME
#define RCFILE_NAME ".nanorc"
@ -159,9 +159,9 @@ void rcfile_error(const char *msg, ...)
fprintf(stderr, "\n");
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
#if defined(ENABLE_NANORC) || !defined(DISABLE_HISTORIES)
/* Parse the next word from the string, null-terminate it, and return
* a pointer to the first character after the null terminator. The
* returned pointer will point to '\0' if we hit the end of the line. */
@ -181,9 +181,9 @@ char *parse_next_word(char *ptr)
return ptr;
}
#endif /* !DISABLE_NANORC || !DISABLE_HISTORIES */
#endif /* ENABLE_NANORC || !DISABLE_HISTORIES */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Parse an argument, with optional quotes, after a keyword that takes
* one. If the next word starts with a ", we say that it ends with the
* last " of the line. Otherwise, we interpret it as usual, so that the
@ -1300,4 +1300,4 @@ void do_rcfiles(void)
}
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */