aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-09 18:32:54 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-09 18:32:54 +0000
commit8465a99ce79ec805ea2063c3f571e2578650a984 (patch)
tree41be7a43b146159cf9e978198c288e72a8131e3f
parentbf678d54237698a79d41ea3ae49d885f0e83bec4 (diff)
downloadbusybox-8465a99ce79ec805ea2063c3f571e2578650a984.tar.gz
less: fix case when regex search finds nothing
-rw-r--r--miscutils/less.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index b81430d07..138bd4711 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -788,19 +788,25 @@ static void normalize_match_pos(int match)
static void goto_match(int match)
{
+ int sv;
+
if (!pattern_valid)
return;
if (match < 0)
match = 0;
+ sv = cur_fline;
/* Try to find next match if eof isn't reached yet */
if (match >= num_matches && eof_error > 0) {
cur_fline = MAXLINES; /* look as far as needed */
read_lines();
- cap_cur_fline(cur_fline);
}
if (num_matches) {
+ cap_cur_fline(cur_fline);
normalize_match_pos(match);
buffer_line(match_lines[match_pos]);
+ } else {
+ cur_fline = sv;
+ print_statusline("No matches found");
}
}