summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko2008-06-09 16:02:39 +0000
committerDenis Vlasenko2008-06-09 16:02:39 +0000
commit3fe4f986a055d0bc942dcda0c2fea3ef68e341d7 (patch)
treeedb986f2879dd8c71d56b31114c84bec043d2197 /miscutils
parent98a6f56d495698a31909afee0acf36f7c9f1d5ee (diff)
downloadbusybox-3fe4f986a055d0bc942dcda0c2fea3ef68e341d7.zip
busybox-3fe4f986a055d0bc942dcda0c2fea3ef68e341d7.tar.gz
less: fix a case when regexp matches ""
hush: remove wrong comment, expand another one
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/less.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 0529b20..ecdb9ae 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -172,16 +172,6 @@ static void set_tty_cooked(void)
tcsetattr(kbd_fd, TCSANOW, &term_orig);
}
-/* Exit the program gracefully */
-static void less_exit(int code)
-{
- bb_putchar('\n');
- set_tty_cooked();
- if (code < 0)
- kill_myself_with_sig(- code); /* does not return */
- exit(code);
-}
-
/* Move the cursor to a position (x,y), where (0,0) is the
top-left corner of the console */
static void move_cursor(int line, int row)
@@ -205,6 +195,16 @@ static void print_statusline(const char *str)
printf(HIGHLIGHT"%.*s"NORMAL, width - 1, str);
}
+/* Exit the program gracefully */
+static void less_exit(int code)
+{
+ set_tty_cooked();
+ clear_line();
+ if (code < 0)
+ kill_myself_with_sig(- code); /* does not return */
+ exit(code);
+}
+
#if ENABLE_FEATURE_LESS_REGEXP
static void fill_match_lines(unsigned pos);
#else
@@ -538,6 +538,9 @@ static void print_found(const char *line)
start:
/* Most of the time doesn't find the regex, optimize for that */
match_status = regexec(&pattern, line, 1, &match_structs, eflags);
+ /* if even "" matches, treat it as "not a match" */
+ if (match_structs.rm_so >= match_structs.rm_eo)
+ match_status = 1;
}
if (!growline) {