From ff35a613553af90b19abf833d749031489fce90d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 29 Oct 2017 19:42:12 +0100 Subject: [PATCH] tweaks: transform the token DISABLE_HISTORIES to ENABLE_HISTORIES --- configure.ac | 12 +++++++----- src/browser.c | 2 +- src/files.c | 8 ++++---- src/global.c | 12 ++++++------ src/history.c | 4 ++-- src/nano.c | 20 ++++++++++---------- src/nano.h | 2 +- src/prompt.c | 20 ++++++++++---------- src/proto.h | 4 ++-- src/rcfile.c | 8 ++++---- src/search.c | 6 +++--- 11 files changed, 50 insertions(+), 48 deletions(-) diff --git a/configure.ac b/configure.ac index ec752a41..21e42c17 100644 --- a/configure.ac +++ b/configure.ac @@ -133,8 +133,13 @@ fi AC_ARG_ENABLE(histories, AS_HELP_STRING([--disable-histories], [Disable search and position histories])) -if test "x$enable_histories" = xno; then - AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.]) +if test "x$enable_tiny" = xyes; then + 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 AC_ARG_ENABLE(justify, @@ -262,9 +267,6 @@ if test "x$enable_tiny" = xyes; then if test "x$enable_extra" != xyes; then AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.]) 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 AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.]) fi diff --git a/src/browser.c b/src/browser.c index cf9e0d1a..a854a244 100644 --- a/src/browser.c +++ b/src/browser.c @@ -765,7 +765,7 @@ void do_filesearch(void) else 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 != '\0') update_history(&search_history, answer); diff --git a/src/files.c b/src/files.c index 21485a47..684f3a74 100644 --- a/src/files.c +++ b/src/files.c @@ -647,7 +647,7 @@ bool close_buffer(void) if (openfile == openfile->next) return FALSE; -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES if (ISSET(POS_HISTORY)) update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1); @@ -1131,7 +1131,7 @@ void do_insertfile(void) * into the buffer, and add the command to the history list. */ if (*answer != '\0') { execute_command(answer); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES update_history(&execute_history, answer); #endif } @@ -1159,7 +1159,7 @@ void do_insertfile(void) #ifdef ENABLE_MULTIBUFFER if (ISSET(MULTIBUFFER)) { -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES if (ISSET(POS_HISTORY)) { ssize_t priorline, priorcol; #ifndef NANO_TINY @@ -1168,7 +1168,7 @@ void do_insertfile(void) if (has_old_position(answer, &priorline, &priorcol)) do_gotolinecolumn(priorline, priorcol, FALSE, FALSE); } -#endif /* !DISABLE_HISTORIES */ +#endif /* ENABLE_HISTORIES */ /* Update stuff to account for the current buffer. */ prepare_for_display(); } else diff --git a/src/global.c b/src/global.c index b28b906d..53c56fd3 100644 --- a/src/global.c +++ b/src/global.c @@ -209,7 +209,7 @@ filestruct *execute_history = NULL; /* The current item in the list of commands that were run with ^R ^X. */ filestruct *replace_history = NULL; /* The current item in the list of replace strings. */ -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES filestruct *searchtop = NULL; /* The oldest item in the list of search strings. */ filestruct *searchbot = NULL; @@ -643,7 +643,7 @@ void shortcut_init(void) N_("Reverse the direction of the search"); const char *regexp_gist = N_("Toggle the use of regular expressions"); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES const char *prevhistory_gist = N_("Recall the previous search/replace string"); const char *nexthistory_gist = @@ -990,7 +990,7 @@ void shortcut_init(void) N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW); #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES add_to_funcs(get_history_older_void, (MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE), N_("PrevHstory"), WITHORSANS(prevhistory_gist), TOGETHER, VIEW); @@ -1283,7 +1283,7 @@ void shortcut_init(void) #endif add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_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, "^N", 0, get_history_newer_void, 0); #ifdef ENABLE_UTF8 @@ -1626,7 +1626,7 @@ sc *strtosc(const char *input) s->scfunc = flip_replace; else if (!strcasecmp(input, "gototext")) s->scfunc = gototext_void; -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES else if (!strcasecmp(input, "prevhistory")) s->scfunc = get_history_older_void; else if (!strcasecmp(input, "nexthistory")) @@ -1849,7 +1849,7 @@ void thanks_for_all_the_fish(void) free(sint); } #endif /* !DISABLE_COLOR */ -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES /* Free the search and replace history lists. */ free_filestruct(searchtop); free_filestruct(replacetop); diff --git a/src/history.c b/src/history.c index 11cf6c20..64d9d028 100644 --- a/src/history.c +++ b/src/history.c @@ -24,7 +24,7 @@ #include #include -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES static bool history_changed = FALSE; /* 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; return TRUE; } -#endif /* !DISABLE_HISTORIES */ +#endif /* ENABLE_HISTORIES */ diff --git a/src/nano.c b/src/nano.c index b3888d9d..5260068c 100644 --- a/src/nano.c +++ b/src/nano.c @@ -564,7 +564,7 @@ void finish(void) /* Restore the old terminal settings. */ tcsetattr(0, TCSANOW, &oldterm); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES /* If the user wants history persistence, write the relevant files. */ if (ISSET(HISTORYLOG)) save_history(); @@ -807,7 +807,7 @@ void usage(void) #ifndef NANO_TINY print_opt("-G", "--locking", N_("Use (vim-style) lock files")); #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES if (!ISSET(RESTRICTED)) print_opt("-H", "--historylog", N_("Log & read search/replace string history")); @@ -825,7 +825,7 @@ void usage(void) N_("Don't convert files from DOS/Mac format")); #endif print_opt("-O", "--morespace", N_("Use one more line for editing")); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES if (!ISSET(RESTRICTED)) print_opt("-P", "--positionlog", N_("Log & read location of cursor position")); @@ -939,7 +939,7 @@ void version(void) #ifdef ENABLE_HELP printf(" --enable-help"); #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES printf(" --enable-histories"); #endif #ifndef DISABLE_JUSTIFY @@ -988,7 +988,7 @@ void version(void) #ifndef ENABLE_HELP printf(" --disable-help"); #endif -#ifdef DISABLE_HISTORIES +#ifndef ENABLE_HISTORIES printf(" --disable-histories"); #endif #ifdef DISABLE_JUSTIFY @@ -2059,7 +2059,7 @@ int main(int argc, char **argv) SET(LOCKING); break; #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES case 'H': SET(HISTORYLOG); break; @@ -2083,7 +2083,7 @@ int main(int argc, char **argv) case 'O': SET(MORE_SPACE); break; -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES case 'P': SET(POS_HISTORY); break; @@ -2354,7 +2354,7 @@ int main(int argc, char **argv) if (ISSET(BOLD_TEXT)) hilite_attribute = A_BOLD; -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES /* Initialize the pointers for the Search/Replace/Execute histories. */ history_init(); @@ -2373,7 +2373,7 @@ int main(int argc, char **argv) load_history(); if (ISSET(POS_HISTORY)) load_poshistory(); -#endif /* !DISABLE_HISTORIES */ +#endif /* ENABLE_HISTORIES */ #ifndef NANO_TINY /* 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 (givenline != 0 || givencol != 0) do_gotolinecolumn(givenline, givencol, FALSE, FALSE); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES else if (ISSET(POS_HISTORY) && openfile->filename[0] != '\0') { ssize_t savedline, savedcol; /* If edited before, restore the last cursor position. */ diff --git a/src/nano.h b/src/nano.h index 3fff8401..aaec37bd 100644 --- a/src/nano.h +++ b/src/nano.h @@ -343,7 +343,7 @@ typedef struct undo { } undo; #endif /* !NANO_TINY */ -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES typedef struct poshiststruct { char *filename; /* The file. */ diff --git a/src/prompt.c b/src/prompt.c index 8ec0f538..6e6b47b0 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -440,7 +440,7 @@ void update_the_statusbar(void) /* Get a string of input at the statusbar prompt. */ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, bool allow_files, bool *listed, -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES filestruct **history_list, #endif void (*refresh_func)(void)) @@ -452,7 +452,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, bool tabbed = FALSE; /* Whether we've pressed Tab. */ #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES char *history = NULL; /* The current history string. */ 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 * tab complete, if any. */ #endif -#endif /* !DISABLE_HISTORIES */ +#endif /* ENABLE_HISTORIES */ if (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) { refresh_func(); *actual = KEY_WINCH; -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES free(magichistory); #endif return NULL; @@ -497,7 +497,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, tabbed = FALSE; if (func == do_tab) { -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES if (history_list != NULL) { if (last_kbinput != the_code_for(do_tab, TAB_CODE)) complete_len = strlen(answer); @@ -514,7 +514,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, &tabbed, refresh_func, listed); } else #endif /* ENABLE_TABCOMP */ -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES if (func == get_history_older_void) { if (history_list != NULL) { /* 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; } } else -#endif /* !DISABLE_HISTORIES */ +#endif /* ENABLE_HISTORIES */ if (func == do_help_void) { /* This key has a shortcut-list entry when it's used to go to * 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(); -#if !defined(DISABLE_HISTORIES) && defined(ENABLE_TABCOMP) +#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP) last_kbinput = kbinput; #endif } -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES /* Set the current position in the history list to the bottom. */ if (history_list != NULL) { 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'; func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed, -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES history_list, #endif refresh_func); diff --git a/src/proto.h b/src/proto.h index 4d71cb95..2ae1e79a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -161,7 +161,7 @@ extern subnfunc *uncutfunc; extern filestruct *search_history; extern filestruct *replace_history; extern filestruct *execute_history; -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES extern filestruct *searchtop; extern filestruct *searchbot; extern filestruct *replacetop; @@ -353,7 +353,7 @@ size_t help_line_len(const char *ptr); void do_help_void(void); /* Most functions in history.c. */ -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES void history_init(void); void history_reset(const filestruct *h); void update_history(filestruct **h, const char *s); diff --git a/src/rcfile.c b/src/rcfile.c index 2988d4fc..c244d961 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -47,7 +47,7 @@ static const rcoption rcopts[] = { #ifndef DISABLE_WRAPJUSTIFY {"fill", 0}, #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES {"historylog", HISTORYLOG}, #endif {"morespace", MORE_SPACE}, @@ -66,7 +66,7 @@ static const rcoption rcopts[] = { #ifndef DISABLE_OPERATINGDIR {"operatingdir", 0}, #endif -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES {"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */ {"positionlog", POS_HISTORY}, #endif @@ -162,7 +162,7 @@ void rcfile_error(const char *msg, ...) } #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 * 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. */ @@ -182,7 +182,7 @@ char *parse_next_word(char *ptr) return ptr; } -#endif /* ENABLE_NANORC || !DISABLE_HISTORIES */ +#endif /* ENABLE_NANORC || ENABLE_HISTORIES */ #ifdef ENABLE_NANORC /* Parse an argument, with optional quotes, after a keyword that takes diff --git a/src/search.c b/src/search.c index 4e59b649..5ce07f2b 100644 --- a/src/search.c +++ b/src/search.c @@ -162,7 +162,7 @@ int search_init(bool replacing, bool use_answer) /* If an answer was given, remember it. */ if (*answer != '\0') { last_search = mallocstrcpy(last_search, answer); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES update_history(&search_history, answer); #endif } @@ -403,7 +403,7 @@ void do_findnext(void) /* Search for the last string without prompting. */ void do_research(void) { -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES /* If nothing was searched for yet during this run of nano, but * there is a search history, take the most recent item. */ if (*last_search == '\0' && searchbot->prev != NULL) @@ -748,7 +748,7 @@ void do_replace(void) /* TRANSLATORS: This is a prompt. */ edit_refresh, _("Replace with")); -#ifndef DISABLE_HISTORIES +#ifdef ENABLE_HISTORIES /* If the replace string is not "", add it to the replace history list. */ if (i == 0) update_history(&replace_history, answer);