* 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
#endif
MGOTODIR, ans,
&meta_key, &func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
NULL,
#endif
/* TRANSLATORS: This is a prompt. */
#endif
MWHEREISFILE, backupstring,
&meta_key, &func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
&search_history,
#endif
browser_refresh, "%s%s%s%s%s", _("Search"),
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')
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
#endif
MINSERTFILE, ans,
&meta_key, &func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, msg,
}
#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
{
#endif
MWRITEFILE, ans,
&meta_key, &func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, "%s%s%s", msg,
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)
free(nanohist);
}
}
-
-#endif /* !NANO_TINY && !DISABLE_NANORC */
+#endif /* !DISABLE_HISTORIES */
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;
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 =
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);
#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);
/* 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)) {
#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
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
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"));
#ifndef DISABLE_HELP
printf(" --enable-help");
#endif
+#ifndef DISABLE_HISTORIES
+ printf(" --enable-histories");
+#endif
#ifndef DISABLE_JUSTIFY
printf(" --enable-justify");
#endif
#ifdef DISABLE_HELP
printf(" --disable-help");
#endif
+#ifdef DISABLE_HISTORIES
+ printf(" --disable-histories");
+#endif
#ifdef DISABLE_JUSTIFY
printf(" --disable-justify");
#endif
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;
case 'O':
SET(MORE_SPACE);
break;
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
case 'P':
SET(POS_HISTORY);
break;
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) {
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
* 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,
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;
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;
/* Another shadow variable. */
struct undo *next;
} undo;
+#endif /* !NANO_TINY */
-
+#ifndef DISABLE_HISTORIES
typedef struct poshiststruct {
char *filename;
/* The file. */
/* x position in the file we left off on. */
struct poshiststruct *next;
} poshiststruct;
-
-#endif /* !NANO_TINY */
-
+#endif
typedef struct openfilestruct {
char *filename;
#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
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;
/* 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);
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);
statusbar_x = strlen(answer);
}
} else
-#endif /* !NANO_TINY */
+#endif
if (allow_tabs)
answer = input_tab(answer, allow_files, &statusbar_x,
&tabbed, refresh_func, list);
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
finished = FALSE;
}
} else
-#endif /* !NANO_TINY */
+#endif /* !DISABLE_HISTORIES */
if (s && s->scfunc == do_help_void) {
update_statusbar_line(answer, statusbar_x);
if (finished)
break;
-#if !defined(NANO_TINY) && !defined(DISABLE_TABCOMP)
+#if !defined(DISABLE_HISTORIES) && !defined(DISABLE_TABCOMP)
last_kbinput = kbinput;
#endif
}
-#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) {
#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, ...)
#endif
curranswer,
meta_key, func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
history_list,
#endif
refresh_func, menu
extern const shortcut *currshortcut;
extern int currmenu;
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
extern filestruct *search_history;
extern filestruct *searchage;
extern filestruct *searchbot;
*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);
#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
#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, ...);
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);
#endif
);
void do_rcfile(void);
-#endif
+#endif /* !DISABLE_NANORC */
/* All functions in search.c. */
#ifdef HAVE_REGEX_H
#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
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. */
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. */
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
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
#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. */
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')
/* 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);
#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)
#endif
MGOTOLINE, use_answer ? ans : "",
&meta_key, &func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
NULL,
#endif
/* TRANSLATORS: This is a prompt. */
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)
*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;
return (char *)s;
}
#endif /* !DISABLE_TABCOMP */
-#endif /* !NANO_TINY */
+#endif /* !DISABLE_HISTORIES */
#endif
MSPELL, word,
&meta_key, &func_key,
-#ifndef NANO_TINY
+#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, _("Edit a replacement")) == -1);