Transform many DISABLE_NANORC #ifdefs to the new DISABLE_HISTORIES.

This completes the fix for Savannah bug #42539.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4989 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2014-06-19 20:05:24 +00:00
parent 0615acd739
commit b341f29cbd
11 changed files with 80 additions and 70 deletions

View File

@ -7,6 +7,8 @@
* configure.ac: Add a --disable-histories flag, to disable the code
for the histories of search/replace strings and cursor positions.
* doc/texinfo/nano.texi: Document the new configure flag.
* src/*: Transform many DISABLE_NANORC to the new DISABLE_HISTORIES.
This completes the fix for Savannah bug #42539.
2014-06-18 Benno Schulenberg <bensberg@justemail.net>
* src/text.c: Rename 'to_end' to 'to_eof', to lessen confusion

View File

@ -213,7 +213,7 @@ char *do_browser(char *path, DIR *dir)
#endif
MGOTODIR, ans,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
NULL,
#endif
/* TRANSLATORS: This is a prompt. */
@ -793,7 +793,7 @@ int filesearch_init(void)
#endif
MWHEREISFILE, backupstring,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
&search_history,
#endif
browser_refresh, "%s%s%s%s%s", _("Search"),
@ -977,7 +977,7 @@ void do_filesearch(void)
else
last_search = mallocstrcpy(last_search, answer);
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
/* If answer is not "", add this search string to the search history
* list. */
if (answer[0] != '\0')

View File

@ -477,7 +477,7 @@ bool close_buffer(void)
if (openfile == openfile->next)
return FALSE;
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef DISABLE_HISTORIES
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1);
#endif
@ -1047,7 +1047,7 @@ void do_insertfile(
#endif
MINSERTFILE, ans,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, msg,
@ -1188,18 +1188,16 @@ void do_insertfile(
}
#endif
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_NANORC)
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_HISTORIES)
if (ISSET(MULTIBUFFER)) {
/* Update the screen to account for the current
* buffer. */
display_buffer();
#ifndef NANO_TINY
ssize_t savedposline, savedposcol;
if (!execute && ISSET(POS_HISTORY)
&& check_poshistory(answer, &savedposline, &savedposcol))
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
#endif
} else
#endif
{
@ -2275,7 +2273,7 @@ bool do_writeout(bool exiting)
#endif
MWRITEFILE, ans,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, "%s%s%s", msg,
@ -2895,8 +2893,8 @@ const char *tail(const char *foo)
return tmp;
}
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
/* Return the constructed dorfile path, or NULL if we can't find the home
#ifndef DISABLE_HISTORIES
/* Return the constructed dirfile path, or NULL if we can't find the home
* directory. The string is dynamically allocated, and should be
* freed. */
char *construct_filename(const char *str)
@ -3233,5 +3231,4 @@ void load_poshistory(void)
free(nanohist);
}
}
#endif /* !NANO_TINY && !DISABLE_NANORC */
#endif /* !DISABLE_HISTORIES */

View File

@ -177,7 +177,7 @@ subnfunc *exitfunc;
subnfunc *uncutfunc;
/* Pointer to the special Uncut/Unjustify item. */
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
filestruct *search_history = NULL;
/* The search string history list. */
filestruct *searchage = NULL;
@ -601,7 +601,7 @@ void shortcut_init(void)
const char *nano_regexp_msg =
N_("Toggle the use of regular expressions");
#endif
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
const char *nano_prev_history_msg =
N_("Recall the previous search/replace string");
const char *nano_next_history_msg =
@ -895,11 +895,10 @@ void shortcut_init(void)
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), IFSCHELP(nano_suspend_msg), TRUE, VIEW);
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
add_to_funcs(get_history_older_void,
(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
N_("PrevHstory"), IFSCHELP(nano_prev_history_msg), FALSE, VIEW);
add_to_funcs(get_history_newer_void,
(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE),
N_("NextHstory"), IFSCHELP(nano_next_history_msg), FALSE, VIEW);
@ -1131,7 +1130,7 @@ void shortcut_init(void)
#endif
add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0, FALSE);
add_to_sclist(MGOTOLINE, "^T", gototext_void, 0, FALSE);
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", get_history_older_void, 0, FALSE);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", get_history_older_void, 0, FALSE);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", get_history_newer_void, 0, FALSE);

View File

@ -612,7 +612,7 @@ void finish(void)
/* Restore the old terminal settings. */
tcsetattr(0, TCSANOW, &oldterm);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef DISABLE_HISTORIES
if (ISSET(HISTORYLOG))
save_history();
if (ISSET(POS_HISTORY)) {
@ -856,13 +856,13 @@ void usage(void)
#ifndef DISABLE_MULTIBUFFER
print_opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
#endif
#ifndef DISABLE_NANORC
#ifndef NANO_TINY
print_opt("-G", "--locking",
N_("Use (vim-style) lock files"));
#endif
#ifndef DISABLE_HISTORIES
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
#endif
print_opt("-I", "--ignorercfiles",
N_("Don't look at nanorc files"));
#endif
@ -875,7 +875,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 NANO_TINY
#ifndef DISABLE_HISTORIES
print_opt("-P", "--poslog",
N_("Log & read location of cursor position"));
#endif
@ -906,8 +906,8 @@ void usage(void)
print_opt("-c", "--const", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
#ifndef NANO_TINY
print_opt("-h", "--help", N_("Show this help text"));
#ifndef NANO_TINY
print_opt("-i", "--autoindent",
N_("Automatically indent new lines"));
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
@ -973,6 +973,9 @@ void version(void)
#ifndef DISABLE_HELP
printf(" --enable-help");
#endif
#ifndef DISABLE_HISTORIES
printf(" --enable-histories");
#endif
#ifndef DISABLE_JUSTIFY
printf(" --enable-justify");
#endif
@ -1013,6 +1016,9 @@ void version(void)
#ifdef DISABLE_HELP
printf(" --disable-help");
#endif
#ifdef DISABLE_HISTORIES
printf(" --disable-histories");
#endif
#ifdef DISABLE_JUSTIFY
printf(" --disable-justify");
#endif
@ -2250,15 +2256,17 @@ int main(int argc, char **argv)
SET(MULTIBUFFER);
break;
#endif
#ifndef DISABLE_NANORC
#ifndef NANO_TINY
case 'G':
SET(LOCKING);
break;
#endif
#ifndef DISABLE_HISTORIES
case 'H':
SET(HISTORYLOG);
break;
#endif
#ifndef DISABLE_NANORC
case 'I':
no_rcfiles = TRUE;
break;
@ -2277,7 +2285,7 @@ int main(int argc, char **argv)
case 'O':
SET(MORE_SPACE);
break;
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
case 'P':
SET(POS_HISTORY);
break;
@ -2527,10 +2535,10 @@ int main(int argc, char **argv)
if (ISSET(BOLD_TEXT))
hilite_attribute = A_BOLD;
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
/* Set up the search/replace history. */
history_init();
#ifndef DISABLE_NANORC
/* Verify that the home directory and ~/.nano subdir exist. */
if (ISSET(HISTORYLOG) || ISSET(POS_HISTORY)) {
get_homedir();
if (homedir == NULL || check_dotnano() == 0) {
@ -2542,8 +2550,9 @@ int main(int argc, char **argv)
load_history();
if (ISSET(POS_HISTORY))
load_poshistory();
#endif /* !DISABLE_NANORC */
#endif /* !DISABLE_HISTORIES */
#ifndef NANO_TINY
/* Set up the backup directory (unless we're using restricted mode,
* in which case backups are disabled, since they would allow
* reading from or writing to files not specified on the command
@ -2551,7 +2560,7 @@ int main(int argc, char **argv)
* that backup files will be saved there. */
if (!ISSET(RESTRICTED))
init_backup_dir();
#endif /* !NANO_TINY */
#endif
#ifndef DISABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there,
@ -2725,7 +2734,7 @@ int main(int argc, char **argv)
iline = 1;
icol = 1;
}
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef DISABLE_HISTORIES
else {
/* See if we have a POS history to use if we haven't overridden it. */
ssize_t savedposline, savedposcol;
@ -2772,7 +2781,7 @@ int main(int argc, char **argv)
if (startline > 1 || startcol > 1)
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
FALSE);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef DISABLE_HISTORIES
else {
/* See if we have a POS history to use if we haven't overridden it. */
ssize_t savedposline, savedposcol;

View File

@ -348,8 +348,9 @@ typedef struct undo {
/* Another shadow variable. */
struct undo *next;
} undo;
#endif /* !NANO_TINY */
#ifndef DISABLE_HISTORIES
typedef struct poshiststruct {
char *filename;
/* The file. */
@ -359,9 +360,7 @@ typedef struct poshiststruct {
/* x position in the file we left off on. */
struct poshiststruct *next;
} poshiststruct;
#endif /* !NANO_TINY */
#endif
typedef struct openfilestruct {
char *filename;

View File

@ -902,7 +902,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
#endif
const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
filestruct **history_list,
#endif
void (*refresh_func)(void), int menu
@ -919,7 +919,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
bool tabbed = FALSE;
/* Whether we've pressed Tab. */
#endif
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
char *history = NULL;
/* The current history string. */
char *magichistory = NULL;
@ -932,7 +932,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
/* The length of the original string that we're trying to
* tab complete, if any. */
#endif
#endif /* !NANO_TINY */
#endif /* !DISABLE_HISTORIES */
answer = mallocstrcpy(answer, curranswer);
curranswer_len = strlen(answer);
@ -989,7 +989,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
tabbed = FALSE;
if (s && s->scfunc == do_tab) {
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
if (history_list != NULL) {
if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I))
complete_len = strlen(answer);
@ -1001,7 +1001,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
statusbar_x = strlen(answer);
}
} else
#endif /* !NANO_TINY */
#endif
if (allow_tabs)
answer = input_tab(answer, allow_files, &statusbar_x,
&tabbed, refresh_func, list);
@ -1009,7 +1009,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
update_statusbar_line(answer, statusbar_x);
} else
#endif /* !DISABLE_TABCOMP */
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
if (s && s->scfunc == get_history_older_void) {
if (history_list != NULL) {
/* If we're scrolling up at the bottom of the history list
@ -1059,7 +1059,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
finished = FALSE;
}
} else
#endif /* !NANO_TINY */
#endif /* !DISABLE_HISTORIES */
if (s && s->scfunc == do_help_void) {
update_statusbar_line(answer, statusbar_x);
@ -1076,7 +1076,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
if (finished)
break;
#if !defined(NANO_TINY) && !defined(DISABLE_TABCOMP)
#if !defined(DISABLE_HISTORIES) && !defined(DISABLE_TABCOMP)
last_kbinput = kbinput;
#endif
@ -1085,7 +1085,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
}
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
/* Set the current position in the history list to the bottom,
* and free magichistory if we need to. */
if (history_list != NULL) {
@ -1138,7 +1138,7 @@ int do_prompt(bool allow_tabs,
#endif
int menu, const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
filestruct **history_list,
#endif
void (*refresh_func)(void), const char *msg, ...)
@ -1170,7 +1170,7 @@ int do_prompt(bool allow_tabs,
#endif
curranswer,
meta_key, func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
history_list,
#endif
refresh_func, menu

View File

@ -114,7 +114,7 @@ extern bool edit_refresh_needed;
extern const shortcut *currshortcut;
extern int currmenu;
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
extern filestruct *search_history;
extern filestruct *searchage;
extern filestruct *searchbot;
@ -334,7 +334,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
*lastwastab, void (*refresh_func)(void), bool *list);
#endif
const char *tail(const char *foo);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef DISABLE_HISTORIES
char *histfilename(void);
void load_history(void);
bool writehist(FILE *hist, filestruct *histhead);
@ -522,7 +522,7 @@ const sc *get_prompt_string(int *value, bool allow_tabs,
#endif
const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
filestruct **history_list,
#endif
void (*refresh_func)(void), int menu
@ -536,7 +536,7 @@ int do_prompt(bool allow_tabs,
#endif
int menu, const char *curranswer,
bool *meta_key, bool *func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
filestruct **history_list,
#endif
void (*refresh_func)(void), const char *msg, ...);
@ -544,9 +544,11 @@ void do_prompt_abort(void);
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
char *parse_next_word(char *ptr);
#endif
#ifndef DISABLE_NANORC
void rcfile_error(const char *msg, ...);
char *parse_next_word(char *ptr);
char *parse_argument(char *ptr);
#ifndef DISABLE_COLOR
char *parse_next_regex(char *ptr);
@ -565,7 +567,7 @@ void parse_rcfile(FILE *rcstream
#endif
);
void do_rcfile(void);
#endif
#endif /* !DISABLE_NANORC */
/* All functions in search.c. */
#ifdef HAVE_REGEX_H
@ -609,9 +611,12 @@ void goto_line_posx(ssize_t line, size_t pos_x);
#ifndef NANO_TINY
bool find_bracket_match(bool reverse, const char *bracket_set);
void do_find_bracket(void);
#ifndef DISABLE_NANORC
bool history_has_changed(void);
#ifndef DISABLE_TABCOMP
char *get_history_completion(filestruct **h, const char *s, size_t len);
#endif
#endif
#ifndef DISABLE_HISTORIES
bool history_has_changed(void);
void history_init(void);
void history_reset(const filestruct *h);
filestruct *find_history(const filestruct *h_start, const filestruct
@ -621,9 +626,6 @@ char *get_history_older(filestruct **h);
char *get_history_newer(filestruct **h);
void get_history_older_void(void);
void get_history_newer_void(void);
#ifndef DISABLE_TABCOMP
char *get_history_completion(filestruct **h, const char *s, size_t len);
#endif
#endif
/* All functions in text.c. */

View File

@ -143,7 +143,9 @@ void rcfile_error(const char *msg, ...)
fprintf(stderr, "\n");
}
#endif /* !DISABLE_NANORC */
#if !defined(DISABLE_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. */
@ -163,7 +165,9 @@ char *parse_next_word(char *ptr)
return ptr;
}
#endif /* !DISABLE_NANORC || !DISABLE_HISTORIES */
#ifndef DISABLE_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

View File

@ -32,7 +32,7 @@
static bool search_last_line = FALSE;
/* Have we gone past the last line while searching? */
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef DISABLE_HISTORIES
static bool history_changed = FALSE;
/* Have any of the history lists changed? */
#endif
@ -178,7 +178,7 @@ int search_init(bool replacing, bool use_answer)
#endif
replacing ? MREPLACE : MWHEREIS, backupstring,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
&search_history,
#endif
/* TRANSLATORS: This is the main search prompt. */
@ -474,7 +474,7 @@ void do_search(void)
else
last_search = mallocstrcpy(last_search, answer);
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
/* If answer is not "", add this search string to the search history
* list. */
if (answer[0] != '\0')
@ -940,7 +940,7 @@ void do_replace(void)
/* If answer is not "", add answer to the search history list and
* copy answer into last_search. */
if (answer[0] != '\0') {
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
update_history(&search_history, answer);
#endif
last_search = mallocstrcpy(last_search, answer);
@ -954,13 +954,13 @@ void do_replace(void)
#endif
MREPLACEWITH, last_replace,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
&replace_history,
#endif
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
/* Add this replace string to the replace history list. i == 0
* means that the string is not "". */
if (i == 0)
@ -1040,7 +1040,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
#endif
MGOTOLINE, use_answer ? ans : "",
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
NULL,
#endif
/* TRANSLATORS: This is a prompt. */
@ -1304,14 +1304,14 @@ void do_find_bracket(void)
free(bracket_set);
free(found_ch);
}
#endif /* !NANO_TINY */
#ifndef DISABLE_NANORC
#ifndef DISABLE_HISTORIES
/* Indicate whether any of the history lists have changed. */
bool history_has_changed(void)
{
return history_changed;
}
#endif
/* Initialize the search and replace history lists. */
void history_init(void)
@ -1408,10 +1408,8 @@ void update_history(filestruct **h, const char *s)
*hbot = (*hbot)->next;
(*hbot)->data = mallocstrcpy(NULL, "");
#ifndef DISABLE_NANORC
/* Indicate that the history's been changed. */
history_changed = TRUE;
#endif
/* Set the current position in the list to the bottom. */
*h = *hbot;
@ -1510,4 +1508,4 @@ char *get_history_completion(filestruct **h, const char *s, size_t len)
return (char *)s;
}
#endif /* !DISABLE_TABCOMP */
#endif /* !NANO_TINY */
#endif /* !DISABLE_HISTORIES */

View File

@ -2377,7 +2377,7 @@ bool do_int_spell_fix(const char *word)
#endif
MSPELL, word,
&meta_key, &func_key,
#ifndef NANO_TINY
#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, _("Edit a replacement")) == -1);