really fix bad #ifdefs; history functions are left out when NANO_SMALL

is defined, and history saving and loading functions are left out when
NANO_SMALL is defined and/or ENABLE_NANORC isn't defined


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2586 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-06-03 19:28:30 +00:00
parent 8e15674c70
commit 1addd601bc
4 changed files with 34 additions and 33 deletions

View File

@ -167,7 +167,7 @@ const shortcut *currshortcut; /* Current shortcut list we're using */
toggle *toggles = NULL; toggle *toggles = NULL;
#endif #endif
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
filestruct *search_history = NULL; filestruct *search_history = NULL;
filestruct *searchage = NULL; filestruct *searchage = NULL;
filestruct *searchbot = NULL; filestruct *searchbot = NULL;
@ -256,9 +256,7 @@ void shortcut_init(bool unjustify)
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
const char *regexp_msg = N_("Regexp"); const char *regexp_msg = N_("Regexp");
#endif #endif
#ifdef ENABLE_NANORC
const char *history_msg = N_("History"); const char *history_msg = N_("History");
#endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
const char *new_buffer_msg = N_("New Buffer"); const char *new_buffer_msg = N_("New Buffer");
#endif #endif
@ -346,10 +344,8 @@ void shortcut_init(bool unjustify)
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
const char *nano_regexp_msg = N_("Use regular expressions"); const char *nano_regexp_msg = N_("Use regular expressions");
#endif #endif
#ifdef ENABLE_NANORC
const char *nano_history_msg = const char *nano_history_msg =
N_("Edit the previous search/replace strings"); N_("Edit the previous search/replace strings");
#endif
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
@ -672,12 +668,10 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif #endif
#ifdef ENABLE_NANORC
/* Translators: try to keep this string under 10 characters long */ /* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg, sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif
/* Translators: try to keep this string under 10 characters long */ /* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg, sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
@ -740,11 +734,9 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif #endif
#ifndef ENABLE_NANORC
sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg, sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
free_shortcutage(&replace_list_2); free_shortcutage(&replace_list_2);
@ -771,7 +763,7 @@ void shortcut_init(bool unjustify)
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_last_line); NANO_NO_KEY, VIEW, do_last_line);
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg, sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);

View File

@ -523,14 +523,19 @@ void do_gotolinecolumn_void(void);
void do_gotopos(int line, size_t pos_x, int pos_y, size_t pos_pww); void do_gotopos(int line, size_t pos_x, int pos_y, size_t pos_pww);
#endif #endif
void do_find_bracket(void); void do_find_bracket(void);
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
#ifdef ENABLE_NANORC
bool history_has_changed(void); bool history_has_changed(void);
#endif
void history_init(void); void history_init(void);
filestruct *find_history(filestruct *h_start, filestruct *h_end, const filestruct *find_history(filestruct *h_start, filestruct *h_end, const
char *s, size_t len); char *s, size_t len);
void update_history(filestruct **h, const char *s); void update_history(filestruct **h, const char *s);
char *get_history_older(filestruct **h); char *get_history_older(filestruct **h);
char *get_history_newer(filestruct **h); char *get_history_newer(filestruct **h);
#ifndef DISABLE_TABCOMP
char *get_history_completion(filestruct **h, char *s, size_t len);
#endif
#endif #endif
/* Public functions in utils.c. */ /* Public functions in utils.c. */
@ -647,7 +652,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
dollars); dollars);
void nanoget_repaint(const char *buf, const char *inputbuf, size_t x); void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer, int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
filestruct **history_list, filestruct **history_list,
#endif #endif
const shortcut *s const shortcut *s
@ -656,7 +661,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
#endif #endif
); );
int statusq(bool allow_tabs, const shortcut *s, const char *curranswer, int statusq(bool allow_tabs, const shortcut *s, const char *curranswer,
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
filestruct **history_list, filestruct **history_list,
#endif #endif
const char *msg, ...); const char *msg, ...);

View File

@ -35,7 +35,7 @@
static bool search_last_line = FALSE; static bool search_last_line = FALSE;
/* Have we gone past the last line while searching? */ /* Have we gone past the last line while searching? */
#ifndef NANO_SMALL #if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
static bool history_changed = FALSE; static bool history_changed = FALSE;
/* Have any of the history lists changed? */ /* Have any of the history lists changed? */
#endif #endif
@ -1118,12 +1118,14 @@ void do_find_bracket(void)
} }
#endif #endif
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
#ifdef ENABLE_NANORC
/* Indicate whether any of the history lists have changed. */ /* Indicate whether any of the history lists have changed. */
bool history_has_changed(void) bool history_has_changed(void)
{ {
return history_changed; return history_changed;
} }
#endif
/* Initialize the search and replace history lists. */ /* Initialize the search and replace history lists. */
void history_init(void) void history_init(void)
@ -1214,8 +1216,10 @@ void update_history(filestruct **h, const char *s)
*hbot = (*hbot)->next; *hbot = (*hbot)->next;
(*hbot)->data = mallocstrcpy(NULL, ""); (*hbot)->data = mallocstrcpy(NULL, "");
#ifdef ENABLE_NANORC
/* Indicate that the history's been changed. */ /* Indicate that the history's been changed. */
history_changed = TRUE; history_changed = TRUE;
#endif
/* Set the current position in the list to the bottom. */ /* Set the current position in the list to the bottom. */
*h = *hbot; *h = *hbot;

View File

@ -2430,7 +2430,7 @@ void nanoget_repaint(const char *buf, const char *inputbuf, size_t x)
/* Get the input from the keyboard; this should only be called from /* Get the input from the keyboard; this should only be called from
* statusq(). */ * statusq(). */
int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer, int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
filestruct **history_list, filestruct **history_list,
#endif #endif
const shortcut *s const shortcut *s
@ -2446,7 +2446,12 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
bool tabbed = FALSE; bool tabbed = FALSE;
/* Whether we've pressed Tab. */ /* Whether we've pressed Tab. */
#endif #endif
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
char *history = NULL;
/* The current history string. */
char *magichistory = NULL;
/* The temporary string typed at the bottom of the history, if
* any. */
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
int last_kbinput = ERR; int last_kbinput = ERR;
/* The key we pressed before the current key. */ /* The key we pressed before the current key. */
@ -2454,12 +2459,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
/* 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
char *history = NULL; #endif /* !NANO_SMALL */
/* The current history string. */
char *magichistory = NULL;
/* The temporary string typed at the bottom of the history, if
* any. */
#endif
answer = mallocstrcpy(answer, curranswer); answer = mallocstrcpy(answer, curranswer);
curranswer_len = strlen(answer); curranswer_len = strlen(answer);
@ -2501,7 +2501,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
switch (kbinput) { switch (kbinput) {
case NANO_TAB_KEY: case NANO_TAB_KEY:
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
if (history_list != NULL) { if (history_list != NULL) {
if (last_kbinput != NANO_TAB_KEY) if (last_kbinput != NANO_TAB_KEY)
complete_len = strlen(answer); complete_len = strlen(answer);
@ -2513,14 +2513,14 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
statusbar_x = strlen(answer); statusbar_x = strlen(answer);
} }
} else } else
#endif #endif /* !NANO_SMALL */
if (allow_tabs) if (allow_tabs)
answer = input_tab(answer, &statusbar_x, &tabbed, answer = input_tab(answer, &statusbar_x, &tabbed,
list); list);
#endif #endif /* !DISABLE_TABCOMP */
break; break;
case NANO_PREVLINE_KEY: case NANO_PREVLINE_KEY:
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
if (history_list != NULL) { if (history_list != NULL) {
/* If we're scrolling up at the bottom of the /* If we're scrolling up at the bottom of the
* history list, answer isn't blank, and * history list, answer isn't blank, and
@ -2546,10 +2546,10 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
* statusbar prompt. */ * statusbar prompt. */
finished = FALSE; finished = FALSE;
} }
#endif /* !NANO_SMALL && ENABLE_NANORC */ #endif /* !NANO_SMALL */
break; break;
case NANO_NEXTLINE_KEY: case NANO_NEXTLINE_KEY:
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
if (history_list != NULL) { if (history_list != NULL) {
/* Get the newer search from the history list and /* Get the newer search from the history list and
* save it in answer. If there is no newer search, * save it in answer. If there is no newer search,
@ -2570,7 +2570,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
statusbar_x = strlen(answer); statusbar_x = strlen(answer);
} }
} }
#endif /* !NANO_SMALL && ENABLE_NANORC */ #endif /* !NANO_SMALL */
break; break;
} }
@ -2580,7 +2580,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
if (finished) if (finished)
break; break;
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) && !defined(DISABLE_TABCOMP) #if !defined(NANO_SMALL) && !defined(DISABLE_TABCOMP)
last_kbinput = kbinput; last_kbinput = kbinput;
#endif #endif
@ -2588,7 +2588,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
wrefresh(bottomwin); wrefresh(bottomwin);
} }
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
/* Free magichistory if we need to. */ /* Free magichistory if we need to. */
if (magichistory != NULL) if (magichistory != NULL)
free(magichistory); free(magichistory);
@ -2611,7 +2611,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
* The allow_tabs parameter indicates whether we should allow tabs to be * The allow_tabs parameter indicates whether we should allow tabs to be
* interpreted. */ * interpreted. */
int statusq(bool allow_tabs, const shortcut *s, const char *curranswer, int statusq(bool allow_tabs, const shortcut *s, const char *curranswer,
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #ifndef NANO_SMALL
filestruct **history_list, filestruct **history_list,
#endif #endif
const char *msg, ...) const char *msg, ...)