+2016-03-19 Benno Schulenberg <bensberg@justemail.net>
+ * src/search.c (search_init): Always remember the last typed string,
+ also when it's an invalid regex. This fixes Savannah bug #47440.
+
2016-03-17 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_research): Use the Search key bindings also during
a Re-search, to enable cancelling. This fixes Savannah bug #47159.
if (i == -2 || i == 0 ) {
#ifdef HAVE_REGEX_H
- /* Use last_search if answer is an empty string, or
- * answer if it isn't. */
- if (ISSET(USE_REGEXP) && !regexp_init((i == -2) ?
- last_search : answer))
+ /* If an answer was given, remember it. */
+ if (*answer != '\0') {
+ last_search = mallocstrcpy(last_search, answer);
+#ifndef DISABLE_HISTORIES
+ update_history(&search_history, answer);
+#endif
+ }
+ if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return -1;
#endif
;
if (i != 0)
return;
- /* If answer is now "", copy last_search into answer. */
+ /* If answer is empty, use what was last searched for. */
if (*answer == '\0')
answer = mallocstrcpy(answer, last_search);
- else
- last_search = mallocstrcpy(last_search, answer);
-
-#ifndef DISABLE_HISTORIES
- /* If answer is not "", add this search string to the search history
- * list. */
- if (answer[0] != '\0')
- update_history(&search_history, answer);
-#endif
findnextstr_wrap_reset();
didfind = findnextstr(
if (i != 0)
return;
- /* If answer is not "", add answer to the search history list and
- * copy answer into last_search. */
- if (answer[0] != '\0') {
-#ifndef DISABLE_HISTORIES
- update_history(&search_history, answer);
-#endif
- last_search = mallocstrcpy(last_search, answer);
- }
-
last_replace = mallocstrcpy(last_replace, "");
i = do_prompt(FALSE,