commit f1b5be4bbf229dadc07db62609ce9ad0ba00a0f9
parent 9ceeabda3893c2938e9e36599b3628ab2448f1d6
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 7 Feb 2018 19:42:19 +0100
tweaks: elide an unneeded variable
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/search.c b/src/search.c
@@ -96,10 +96,10 @@ void search_init(bool replacing, bool keep_the_answer)
{
char *thedefault;
/* What will be searched for when the user typed nothing. */
- static char *sofar = NULL;
- /* What the user has typed so far, before toggling something. */
- sofar = mallocstrcpy(sofar, keep_the_answer ? answer : "");
+ /* When starting a new search, clear the current answer. */
+ if (!keep_the_answer)
+ answer = mallocstrcpy(answer, NULL);
/* If something was searched for earlier, include it in the prompt. */
if (*last_search != '\0') {
@@ -118,7 +118,7 @@ void search_init(bool replacing, bool keep_the_answer)
/* Ask the user what to search for (or replace). */
int i = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
- sofar, &search_history,
+ answer, &search_history,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
@@ -168,8 +168,6 @@ void search_init(bool replacing, bool keep_the_answer)
return;
}
- sofar = mallocstrcpy(sofar, answer);
-
func = func_from_key(&i);
/* If we're here, one of the five toggles was pressed, or