tweaks: transform the token DISABLE_HISTORIES to ENABLE_HISTORIES

master
Benno Schulenberg 2017-10-29 19:42:12 +01:00
parent 3f27c312c4
commit ff35a61355
11 changed files with 50 additions and 48 deletions

View File

@ -133,8 +133,13 @@ fi
AC_ARG_ENABLE(histories, AC_ARG_ENABLE(histories,
AS_HELP_STRING([--disable-histories], [Disable search and position histories])) AS_HELP_STRING([--disable-histories], [Disable search and position histories]))
if test "x$enable_histories" = xno; then if test "x$enable_tiny" = xyes; then
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.]) if test "x$enable_histories" != xyes; then
enable_histories=no
fi
fi
if test "x$enable_histories" != xno; then
AC_DEFINE(ENABLE_HISTORIES, 1, [Define this to have search and position histories.])
fi fi
AC_ARG_ENABLE(justify, AC_ARG_ENABLE(justify,
@ -262,9 +267,6 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_extra" != xyes; then if test "x$enable_extra" != xyes; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.]) AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi fi
if test "x$enable_histories" != xyes; then
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
fi
if test "x$enable_justify" != xyes; then if test "x$enable_justify" != xyes; then
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.]) AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
fi fi

View File

@ -765,7 +765,7 @@ void do_filesearch(void)
else else
last_search = mallocstrcpy(last_search, answer); last_search = mallocstrcpy(last_search, answer);
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* If answer is not empty, add the string to the search history list. */ /* If answer is not empty, add the string to the search history list. */
if (*answer != '\0') if (*answer != '\0')
update_history(&search_history, answer); update_history(&search_history, answer);

View File

@ -647,7 +647,7 @@ bool close_buffer(void)
if (openfile == openfile->next) if (openfile == openfile->next)
return FALSE; return FALSE;
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (ISSET(POS_HISTORY)) if (ISSET(POS_HISTORY))
update_poshistory(openfile->filename, update_poshistory(openfile->filename,
openfile->current->lineno, xplustabs() + 1); openfile->current->lineno, xplustabs() + 1);
@ -1131,7 +1131,7 @@ void do_insertfile(void)
* into the buffer, and add the command to the history list. */ * into the buffer, and add the command to the history list. */
if (*answer != '\0') { if (*answer != '\0') {
execute_command(answer); execute_command(answer);
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
update_history(&execute_history, answer); update_history(&execute_history, answer);
#endif #endif
} }
@ -1159,7 +1159,7 @@ void do_insertfile(void)
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) { if (ISSET(MULTIBUFFER)) {
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (ISSET(POS_HISTORY)) { if (ISSET(POS_HISTORY)) {
ssize_t priorline, priorcol; ssize_t priorline, priorcol;
#ifndef NANO_TINY #ifndef NANO_TINY
@ -1168,7 +1168,7 @@ void do_insertfile(void)
if (has_old_position(answer, &priorline, &priorcol)) if (has_old_position(answer, &priorline, &priorcol))
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE); do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
} }
#endif /* !DISABLE_HISTORIES */ #endif /* ENABLE_HISTORIES */
/* Update stuff to account for the current buffer. */ /* Update stuff to account for the current buffer. */
prepare_for_display(); prepare_for_display();
} else } else

View File

@ -209,7 +209,7 @@ filestruct *execute_history = NULL;
/* The current item in the list of commands that were run with ^R ^X. */ /* The current item in the list of commands that were run with ^R ^X. */
filestruct *replace_history = NULL; filestruct *replace_history = NULL;
/* The current item in the list of replace strings. */ /* The current item in the list of replace strings. */
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
filestruct *searchtop = NULL; filestruct *searchtop = NULL;
/* The oldest item in the list of search strings. */ /* The oldest item in the list of search strings. */
filestruct *searchbot = NULL; filestruct *searchbot = NULL;
@ -643,7 +643,7 @@ void shortcut_init(void)
N_("Reverse the direction of the search"); N_("Reverse the direction of the search");
const char *regexp_gist = const char *regexp_gist =
N_("Toggle the use of regular expressions"); N_("Toggle the use of regular expressions");
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
const char *prevhistory_gist = const char *prevhistory_gist =
N_("Recall the previous search/replace string"); N_("Recall the previous search/replace string");
const char *nexthistory_gist = const char *nexthistory_gist =
@ -990,7 +990,7 @@ void shortcut_init(void)
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW); N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
add_to_funcs(get_history_older_void, add_to_funcs(get_history_older_void,
(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE), (MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
N_("PrevHstory"), WITHORSANS(prevhistory_gist), TOGETHER, VIEW); N_("PrevHstory"), WITHORSANS(prevhistory_gist), TOGETHER, VIEW);
@ -1283,7 +1283,7 @@ void shortcut_init(void)
#endif #endif
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0); add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0); add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^P", 0, get_history_older_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^N", 0, get_history_newer_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
@ -1626,7 +1626,7 @@ sc *strtosc(const char *input)
s->scfunc = flip_replace; s->scfunc = flip_replace;
else if (!strcasecmp(input, "gototext")) else if (!strcasecmp(input, "gototext"))
s->scfunc = gototext_void; s->scfunc = gototext_void;
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
else if (!strcasecmp(input, "prevhistory")) else if (!strcasecmp(input, "prevhistory"))
s->scfunc = get_history_older_void; s->scfunc = get_history_older_void;
else if (!strcasecmp(input, "nexthistory")) else if (!strcasecmp(input, "nexthistory"))
@ -1849,7 +1849,7 @@ void thanks_for_all_the_fish(void)
free(sint); free(sint);
} }
#endif /* !DISABLE_COLOR */ #endif /* !DISABLE_COLOR */
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* Free the search and replace history lists. */ /* Free the search and replace history lists. */
free_filestruct(searchtop); free_filestruct(searchtop);
free_filestruct(replacetop); free_filestruct(replacetop);

View File

@ -24,7 +24,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
static bool history_changed = FALSE; static bool history_changed = FALSE;
/* Whether any of the history lists has changed. */ /* Whether any of the history lists has changed. */
@ -568,4 +568,4 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
*column = posptr->xno; *column = posptr->xno;
return TRUE; return TRUE;
} }
#endif /* !DISABLE_HISTORIES */ #endif /* ENABLE_HISTORIES */

View File

@ -564,7 +564,7 @@ void finish(void)
/* Restore the old terminal settings. */ /* Restore the old terminal settings. */
tcsetattr(0, TCSANOW, &oldterm); tcsetattr(0, TCSANOW, &oldterm);
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* If the user wants history persistence, write the relevant files. */ /* If the user wants history persistence, write the relevant files. */
if (ISSET(HISTORYLOG)) if (ISSET(HISTORYLOG))
save_history(); save_history();
@ -807,7 +807,7 @@ void usage(void)
#ifndef NANO_TINY #ifndef NANO_TINY
print_opt("-G", "--locking", N_("Use (vim-style) lock files")); print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
print_opt("-H", "--historylog", print_opt("-H", "--historylog",
N_("Log & read search/replace string history")); N_("Log & read search/replace string history"));
@ -825,7 +825,7 @@ void usage(void)
N_("Don't convert files from DOS/Mac format")); N_("Don't convert files from DOS/Mac format"));
#endif #endif
print_opt("-O", "--morespace", N_("Use one more line for editing")); print_opt("-O", "--morespace", N_("Use one more line for editing"));
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
print_opt("-P", "--positionlog", print_opt("-P", "--positionlog",
N_("Log & read location of cursor position")); N_("Log & read location of cursor position"));
@ -939,7 +939,7 @@ void version(void)
#ifdef ENABLE_HELP #ifdef ENABLE_HELP
printf(" --enable-help"); printf(" --enable-help");
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
printf(" --enable-histories"); printf(" --enable-histories");
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
@ -988,7 +988,7 @@ void version(void)
#ifndef ENABLE_HELP #ifndef ENABLE_HELP
printf(" --disable-help"); printf(" --disable-help");
#endif #endif
#ifdef DISABLE_HISTORIES #ifndef ENABLE_HISTORIES
printf(" --disable-histories"); printf(" --disable-histories");
#endif #endif
#ifdef DISABLE_JUSTIFY #ifdef DISABLE_JUSTIFY
@ -2059,7 +2059,7 @@ int main(int argc, char **argv)
SET(LOCKING); SET(LOCKING);
break; break;
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
case 'H': case 'H':
SET(HISTORYLOG); SET(HISTORYLOG);
break; break;
@ -2083,7 +2083,7 @@ int main(int argc, char **argv)
case 'O': case 'O':
SET(MORE_SPACE); SET(MORE_SPACE);
break; break;
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
case 'P': case 'P':
SET(POS_HISTORY); SET(POS_HISTORY);
break; break;
@ -2354,7 +2354,7 @@ int main(int argc, char **argv)
if (ISSET(BOLD_TEXT)) if (ISSET(BOLD_TEXT))
hilite_attribute = A_BOLD; hilite_attribute = A_BOLD;
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* Initialize the pointers for the Search/Replace/Execute histories. */ /* Initialize the pointers for the Search/Replace/Execute histories. */
history_init(); history_init();
@ -2373,7 +2373,7 @@ int main(int argc, char **argv)
load_history(); load_history();
if (ISSET(POS_HISTORY)) if (ISSET(POS_HISTORY))
load_poshistory(); load_poshistory();
#endif /* !DISABLE_HISTORIES */ #endif /* ENABLE_HISTORIES */
#ifndef NANO_TINY #ifndef NANO_TINY
/* If backups are enabled and a backup directory was specified and /* If backups are enabled and a backup directory was specified and
@ -2567,7 +2567,7 @@ int main(int argc, char **argv)
/* If a position was given on the command line, go there. */ /* If a position was given on the command line, go there. */
if (givenline != 0 || givencol != 0) if (givenline != 0 || givencol != 0)
do_gotolinecolumn(givenline, givencol, FALSE, FALSE); do_gotolinecolumn(givenline, givencol, FALSE, FALSE);
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
else if (ISSET(POS_HISTORY) && openfile->filename[0] != '\0') { else if (ISSET(POS_HISTORY) && openfile->filename[0] != '\0') {
ssize_t savedline, savedcol; ssize_t savedline, savedcol;
/* If edited before, restore the last cursor position. */ /* If edited before, restore the last cursor position. */

View File

@ -343,7 +343,7 @@ typedef struct undo {
} undo; } undo;
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
typedef struct poshiststruct { typedef struct poshiststruct {
char *filename; char *filename;
/* The file. */ /* The file. */

View File

@ -440,7 +440,7 @@ void update_the_statusbar(void)
/* Get a string of input at the statusbar prompt. */ /* Get a string of input at the statusbar prompt. */
functionptrtype acquire_an_answer(int *actual, bool allow_tabs, functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
bool allow_files, bool *listed, bool allow_files, bool *listed,
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
filestruct **history_list, filestruct **history_list,
#endif #endif
void (*refresh_func)(void)) void (*refresh_func)(void))
@ -452,7 +452,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
bool tabbed = FALSE; bool tabbed = FALSE;
/* Whether we've pressed Tab. */ /* Whether we've pressed Tab. */
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
char *history = NULL; char *history = NULL;
/* The current history string. */ /* The current history string. */
char *magichistory = NULL; char *magichistory = NULL;
@ -465,7 +465,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
/* The length of the original string that we're trying to /* The length of the original string that we're trying to
* tab complete, if any. */ * tab complete, if any. */
#endif #endif
#endif /* !DISABLE_HISTORIES */ #endif /* ENABLE_HISTORIES */
if (statusbar_x > strlen(answer)) if (statusbar_x > strlen(answer))
statusbar_x = strlen(answer); statusbar_x = strlen(answer);
@ -480,7 +480,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (kbinput == KEY_WINCH) { if (kbinput == KEY_WINCH) {
refresh_func(); refresh_func();
*actual = KEY_WINCH; *actual = KEY_WINCH;
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
free(magichistory); free(magichistory);
#endif #endif
return NULL; return NULL;
@ -497,7 +497,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
tabbed = FALSE; tabbed = FALSE;
if (func == do_tab) { if (func == do_tab) {
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (history_list != NULL) { if (history_list != NULL) {
if (last_kbinput != the_code_for(do_tab, TAB_CODE)) if (last_kbinput != the_code_for(do_tab, TAB_CODE))
complete_len = strlen(answer); complete_len = strlen(answer);
@ -514,7 +514,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
&tabbed, refresh_func, listed); &tabbed, refresh_func, listed);
} else } else
#endif /* ENABLE_TABCOMP */ #endif /* ENABLE_TABCOMP */
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (func == get_history_older_void) { if (func == get_history_older_void) {
if (history_list != NULL) { if (history_list != NULL) {
/* If we're scrolling up at the bottom of the history list /* If we're scrolling up at the bottom of the history list
@ -560,7 +560,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
finished = FALSE; finished = FALSE;
} }
} else } else
#endif /* !DISABLE_HISTORIES */ #endif /* ENABLE_HISTORIES */
if (func == do_help_void) { if (func == do_help_void) {
/* This key has a shortcut-list entry when it's used to go to /* This key has a shortcut-list entry when it's used to go to
* the help browser or display a message indicating that help * the help browser or display a message indicating that help
@ -577,12 +577,12 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar(); update_the_statusbar();
#if !defined(DISABLE_HISTORIES) && defined(ENABLE_TABCOMP) #if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput; last_kbinput = kbinput;
#endif #endif
} }
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* Set the current position in the history list to the bottom. */ /* Set the current position in the history list to the bottom. */
if (history_list != NULL) { if (history_list != NULL) {
history_reset(*history_list); history_reset(*history_list);
@ -633,7 +633,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0'; prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0';
func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed, func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed,
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
history_list, history_list,
#endif #endif
refresh_func); refresh_func);

View File

@ -161,7 +161,7 @@ extern subnfunc *uncutfunc;
extern filestruct *search_history; extern filestruct *search_history;
extern filestruct *replace_history; extern filestruct *replace_history;
extern filestruct *execute_history; extern filestruct *execute_history;
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
extern filestruct *searchtop; extern filestruct *searchtop;
extern filestruct *searchbot; extern filestruct *searchbot;
extern filestruct *replacetop; extern filestruct *replacetop;
@ -353,7 +353,7 @@ size_t help_line_len(const char *ptr);
void do_help_void(void); void do_help_void(void);
/* Most functions in history.c. */ /* Most functions in history.c. */
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
void history_init(void); void history_init(void);
void history_reset(const filestruct *h); void history_reset(const filestruct *h);
void update_history(filestruct **h, const char *s); void update_history(filestruct **h, const char *s);

View File

@ -47,7 +47,7 @@ static const rcoption rcopts[] = {
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
{"fill", 0}, {"fill", 0},
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
{"historylog", HISTORYLOG}, {"historylog", HISTORYLOG},
#endif #endif
{"morespace", MORE_SPACE}, {"morespace", MORE_SPACE},
@ -66,7 +66,7 @@ static const rcoption rcopts[] = {
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
{"operatingdir", 0}, {"operatingdir", 0},
#endif #endif
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
{"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */ {"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */
{"positionlog", POS_HISTORY}, {"positionlog", POS_HISTORY},
#endif #endif
@ -162,7 +162,7 @@ void rcfile_error(const char *msg, ...)
} }
#endif /* ENABLE_NANORC */ #endif /* ENABLE_NANORC */
#if defined(ENABLE_NANORC) || !defined(DISABLE_HISTORIES) #if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
/* Parse the next word from the string, null-terminate it, and return /* Parse the next word from the string, null-terminate it, and return
* a pointer to the first character after the null terminator. The * 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. */ * returned pointer will point to '\0' if we hit the end of the line. */
@ -182,7 +182,7 @@ char *parse_next_word(char *ptr)
return ptr; return ptr;
} }
#endif /* ENABLE_NANORC || !DISABLE_HISTORIES */ #endif /* ENABLE_NANORC || ENABLE_HISTORIES */
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
/* Parse an argument, with optional quotes, after a keyword that takes /* Parse an argument, with optional quotes, after a keyword that takes

View File

@ -162,7 +162,7 @@ int search_init(bool replacing, bool use_answer)
/* If an answer was given, remember it. */ /* If an answer was given, remember it. */
if (*answer != '\0') { if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer); last_search = mallocstrcpy(last_search, answer);
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
update_history(&search_history, answer); update_history(&search_history, answer);
#endif #endif
} }
@ -403,7 +403,7 @@ void do_findnext(void)
/* Search for the last string without prompting. */ /* Search for the last string without prompting. */
void do_research(void) void do_research(void)
{ {
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* If nothing was searched for yet during this run of nano, but /* If nothing was searched for yet during this run of nano, but
* there is a search history, take the most recent item. */ * there is a search history, take the most recent item. */
if (*last_search == '\0' && searchbot->prev != NULL) if (*last_search == '\0' && searchbot->prev != NULL)
@ -748,7 +748,7 @@ void do_replace(void)
/* TRANSLATORS: This is a prompt. */ /* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with")); edit_refresh, _("Replace with"));
#ifndef DISABLE_HISTORIES #ifdef ENABLE_HISTORIES
/* If the replace string is not "", add it to the replace history list. */ /* If the replace string is not "", add it to the replace history list. */
if (i == 0) if (i == 0)
update_history(&replace_history, answer); update_history(&replace_history, answer);