tweaks: pass an empty string as an answer instead of a NULL pointer

Also, rename a parameter, to be more distinct and to avoid an abbrev.
master
Benno Schulenberg 2019-10-15 13:39:03 +02:00
parent 48b94d71c7
commit bc91af2e3c
3 changed files with 8 additions and 8 deletions

View File

@ -221,7 +221,7 @@ char *do_browser(char *path)
selected = filelist_len - 1;
} else if (func == goto_dir_void) {
/* Ask for the directory to go to. */
if (do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL,
if (do_prompt(TRUE, FALSE, MGOTODIR, "", NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory")) < 0) {
statusbar(_("Cancelled"));
@ -667,7 +667,7 @@ int filesearch_init(bool forwards)
thedefault = copy_of("");
/* Now ask what to search for. */
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
response = do_prompt(FALSE, FALSE, MWHEREISFILE, "", &search_history,
browser_refresh, "%s%s%s", _("Search"),
/* TRANSLATORS: A modifier of the Search prompt. */
!forwards ? _(" [Backwards]") : "", thedefault);

View File

@ -581,10 +581,10 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
*
* The allow_tabs parameter indicates whether tab completion is allowed,
* and allow_files indicates whether all files (and not just directories)
* can be tab completed. The curranswer parameter is the default answer
* can be tab completed. The 'provided' parameter is the default answer
* for when simply Enter is typed. */
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, linestruct **history_list,
int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...)
{
va_list ap;
@ -597,8 +597,8 @@ int do_prompt(bool allow_tabs, bool allow_files,
bottombars(menu);
if (answer != curranswer || answer == NULL)
answer = mallocstrcpy(answer, curranswer);
if (answer != provided)
answer = mallocstrcpy(answer, provided);
#ifndef NANO_TINY
redo_theprompt:

View File

@ -699,7 +699,7 @@ void ask_for_replacement(void)
linestruct *edittop_save, *begin;
size_t firstcolumn_save, begin_x;
ssize_t numreplaced;
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL,
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, "",
/* TRANSLATORS: This is a prompt. */
&replace_history, edit_refresh, _("Replace with"));
@ -758,7 +758,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
if (interactive) {
/* Ask for the line and column. */
int response = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : NULL, NULL, edit_refresh,
use_answer ? answer : "", NULL, edit_refresh,
/* TRANSLATORS: This is a prompt. */
_("Enter line number, column number"));