52 lines
1.5 KiB
Diff
52 lines
1.5 KiB
Diff
From 9b718ada456d49c795278328ed9d4d6f7f19686d Mon Sep 17 00:00:00 2001
|
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
|
Date: Wed, 13 Jan 2021 14:25:21 -0800
|
|
Subject: [PATCH] Make histpattern return negative value to indicate error.
|
|
Avoid "Pattern not found" message after "Invalid pattern".
|
|
---
|
|
search.c | 13 ++++++++++++---------
|
|
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/search.c b/search.c
|
|
index 43b90a5..1165ba3 100644
|
|
--- a/search.c
|
|
+++ b/search.c
|
|
@@ -1413,7 +1413,7 @@ hist_pattern(search_type)
|
|
return (0);
|
|
|
|
if (set_pattern(&search_info, pattern, search_type) < 0)
|
|
- return (0);
|
|
+ return (-1);
|
|
|
|
#if HILITE_SEARCH
|
|
if (hilite_search == OPT_ONPLUS && !hide_hilite)
|
|
@@ -1446,7 +1446,7 @@ chg_caseless(VOID_PARAM)
|
|
* Regenerate the pattern using the new state.
|
|
*/
|
|
clear_pattern(&search_info);
|
|
- hist_pattern(search_info.search_type);
|
|
+ (void) hist_pattern(search_info.search_type);
|
|
}
|
|
}
|
|
|
|
@@ -1474,10 +1474,13 @@ search(search_type, pattern, n)
|
|
* A null pattern means use the previously compiled pattern.
|
|
*/
|
|
search_type |= SRCH_AFTER_TARGET;
|
|
- if (!prev_pattern(&search_info) && !hist_pattern(search_type))
|
|
+ if (!prev_pattern(&search_info))
|
|
{
|
|
- error("No previous regular expression", NULL_PARG);
|
|
- return (-1);
|
|
+ int r = hist_pattern(search_type);
|
|
+ if (r == 0)
|
|
+ error("No previous regular expression", NULL_PARG);
|
|
+ if (r <= 0)
|
|
+ return (-1);
|
|
}
|
|
if ((search_type & SRCH_NO_REGEX) !=
|
|
(search_info.search_type & SRCH_NO_REGEX))
|
|
--
|
|
1.8.3.1
|
|
|