Commit 3f27c312 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: get rid of some cluttering conditional compilation

In the tiny version, do_prompt() will now have an extra NULL
parameter, which will cost maybe twenty extra bytes of code.
That is acceptable when it saves thirty lines in the source.
No related merge requests found
Showing with 18 additions and 48 deletions
+18 -48
...@@ -225,10 +225,7 @@ char *do_browser(char *path) ...@@ -225,10 +225,7 @@ char *do_browser(char *path)
selected = filelist_len - 1; selected = filelist_len - 1;
} else if (func == goto_dir_void) { } else if (func == goto_dir_void) {
/* Ask for the directory to go to. */ /* Ask for the directory to go to. */
int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL, int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL,
#ifndef DISABLE_HISTORIES
NULL,
#endif
/* TRANSLATORS: This is a prompt. */ /* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory")); browser_refresh, _("Go To Directory"));
...@@ -679,10 +676,7 @@ int filesearch_init(void) ...@@ -679,10 +676,7 @@ int filesearch_init(void)
buf = mallocstrcpy(NULL, ""); buf = mallocstrcpy(NULL, "");
/* This is now one simple call. It just does a lot. */ /* This is now one simple call. It just does a lot. */
input = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, input = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
#ifndef DISABLE_HISTORIES
&search_history,
#endif
browser_refresh, "%s%s", _("Search"), buf); browser_refresh, "%s%s", _("Search"), buf);
/* Release buf now that we don't need it anymore. */ /* Release buf now that we don't need it anymore. */
......
...@@ -1065,13 +1065,10 @@ void do_insertfile(void) ...@@ -1065,13 +1065,10 @@ void do_insertfile(void)
execute ? MEXTCMD : execute ? MEXTCMD :
#endif #endif
MINSERTFILE, given, MINSERTFILE, given,
#ifndef DISABLE_HISTORIES
#ifndef NANO_TINY #ifndef NANO_TINY
execute ? &execute_history : execute ? &execute_history :
#endif #endif
NULL, NULL, edit_refresh, msg,
#endif
edit_refresh, msg,
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
operating_dir != NULL ? operating_dir : operating_dir != NULL ? operating_dir :
#endif #endif
...@@ -2082,10 +2079,7 @@ int do_writeout(bool exiting, bool withprompt) ...@@ -2082,10 +2079,7 @@ int do_writeout(bool exiting, bool withprompt)
/* Ask for (confirmation of) the filename. Disable tab completion /* Ask for (confirmation of) the filename. Disable tab completion
* when using restricted mode and the filename isn't blank. */ * when using restricted mode and the filename isn't blank. */
i = do_prompt(!ISSET(RESTRICTED) || openfile->filename[0] == '\0', i = do_prompt(!ISSET(RESTRICTED) || openfile->filename[0] == '\0',
TRUE, MWRITEFILE, given, TRUE, MWRITEFILE, given, NULL,
#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, "%s%s%s", msg, edit_refresh, "%s%s%s", msg,
#ifndef NANO_TINY #ifndef NANO_TINY
formatstr, backupstr formatstr, backupstr
......
...@@ -203,21 +203,21 @@ subnfunc *exitfunc; ...@@ -203,21 +203,21 @@ subnfunc *exitfunc;
subnfunc *uncutfunc; subnfunc *uncutfunc;
/* A pointer to the special Uncut/Unjustify item. */ /* A pointer to the special Uncut/Unjustify item. */
#ifndef DISABLE_HISTORIES
filestruct *search_history = NULL; filestruct *search_history = NULL;
/* The current item in the list of strings that were searched for. */ /* The current item in the list of strings that were searched for. */
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
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;
/* The newest item in the list of search strings. */ /* The newest item in the list of search strings. */
filestruct *replace_history = NULL;
/* The current item in the list of replace strings. */
filestruct *replacetop = NULL; filestruct *replacetop = NULL;
filestruct *replacebot = NULL; filestruct *replacebot = NULL;
filestruct *execute_history = NULL;
/* The current item in the list of commands that were run with ^R ^X. */
filestruct *executetop = NULL; filestruct *executetop = NULL;
filestruct *executebot = NULL; filestruct *executebot = NULL;
......
...@@ -607,10 +607,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs, ...@@ -607,10 +607,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
* interpreted. The allow_files parameter indicates whether we should * interpreted. The allow_files parameter indicates whether we should
* allow all files (as opposed to just directories) to be tab completed. */ * allow all files (as opposed to just directories) to be tab completed. */
int do_prompt(bool allow_tabs, bool allow_files, int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, int menu, const char *curranswer, filestruct **history_list,
#ifndef DISABLE_HISTORIES
filestruct **history_list,
#endif
void (*refresh_func)(void), const char *msg, ...) void (*refresh_func)(void), const char *msg, ...)
{ {
va_list ap; va_list ap;
......
...@@ -158,14 +158,14 @@ extern subnfunc *allfuncs; ...@@ -158,14 +158,14 @@ extern subnfunc *allfuncs;
extern subnfunc *exitfunc; extern subnfunc *exitfunc;
extern subnfunc *uncutfunc; extern subnfunc *uncutfunc;
#ifndef DISABLE_HISTORIES
extern filestruct *search_history; extern filestruct *search_history;
extern filestruct *replace_history;
extern filestruct *execute_history;
#ifndef DISABLE_HISTORIES
extern filestruct *searchtop; extern filestruct *searchtop;
extern filestruct *searchbot; extern filestruct *searchbot;
extern filestruct *replace_history;
extern filestruct *replacetop; extern filestruct *replacetop;
extern filestruct *replacebot; extern filestruct *replacebot;
extern filestruct *execute_history;
extern filestruct *executetop; extern filestruct *executetop;
extern filestruct *executebot; extern filestruct *executebot;
extern poshiststruct *position_history; extern poshiststruct *position_history;
...@@ -477,10 +477,7 @@ size_t get_statusbar_page_start(size_t start_col, size_t column); ...@@ -477,10 +477,7 @@ size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void); void reinit_statusbar_x(void);
void update_the_statusbar(void); void update_the_statusbar(void);
int do_prompt(bool allow_tabs, bool allow_files, int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, int menu, const char *curranswer, filestruct **history_list,
#ifndef DISABLE_HISTORIES
filestruct **history_list,
#endif
void (*refresh_func)(void), const char *msg, ...); void (*refresh_func)(void), const char *msg, ...);
int do_yesno_prompt(bool all, const char *msg); int do_yesno_prompt(bool all, const char *msg);
......
...@@ -131,10 +131,7 @@ int search_init(bool replacing, bool use_answer) ...@@ -131,10 +131,7 @@ int search_init(bool replacing, bool use_answer)
/* This is now one simple call. It just does a lot. */ /* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, FALSE, i = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS), inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
backupstring, backupstring, &search_history,
#ifndef DISABLE_HISTORIES
&search_history,
#endif
/* TRANSLATORS: This is the main search prompt. */ /* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"), edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */ /* TRANSLATORS: The next three modify the search prompt. */
...@@ -747,10 +744,7 @@ void do_replace(void) ...@@ -747,10 +744,7 @@ void do_replace(void)
if (i != 0) if (i != 0)
return; return;
i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
#ifndef DISABLE_HISTORIES
&replace_history,
#endif
/* TRANSLATORS: This is a prompt. */ /* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with")); edit_refresh, _("Replace with"));
...@@ -815,10 +809,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, ...@@ -815,10 +809,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* Ask for the line and column. */ /* Ask for the line and column. */
int i = do_prompt(FALSE, FALSE, MGOTOLINE, int i = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : NULL, use_answer ? answer : NULL, NULL,
#ifndef DISABLE_HISTORIES
NULL,
#endif
/* TRANSLATORS: This is a prompt. */ /* TRANSLATORS: This is a prompt. */
edit_refresh, _("Enter line number, column number")); edit_refresh, _("Enter line number, column number"));
......
...@@ -2636,10 +2636,7 @@ bool do_int_spell_fix(const char *word) ...@@ -2636,10 +2636,7 @@ bool do_int_spell_fix(const char *word)
spotlight(TRUE, from_col, to_col); spotlight(TRUE, from_col, to_col);
/* Let the user supply a correctly spelled alternative. */ /* Let the user supply a correctly spelled alternative. */
proceed = (do_prompt(FALSE, FALSE, MSPELL, word, proceed = (do_prompt(FALSE, FALSE, MSPELL, word, NULL,
#ifndef DISABLE_HISTORIES
NULL,
#endif
edit_refresh, _("Edit a replacement")) != -1); edit_refresh, _("Edit a replacement")) != -1);
spotlight(FALSE, from_col, to_col); spotlight(FALSE, from_col, to_col);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment