aboutsummaryrefslogtreecommitdiff
path: root/miscutils/less.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-09 16:02:39 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-09 16:02:39 +0000
commit3fe4f986a055d0bc942dcda0c2fea3ef68e341d7 (patch)
treeedb986f2879dd8c71d56b31114c84bec043d2197 /miscutils/less.c
parent98a6f56d495698a31909afee0acf36f7c9f1d5ee (diff)
downloadbusybox-w32-3fe4f986a055d0bc942dcda0c2fea3ef68e341d7.tar.gz
busybox-w32-3fe4f986a055d0bc942dcda0c2fea3ef68e341d7.tar.bz2
busybox-w32-3fe4f986a055d0bc942dcda0c2fea3ef68e341d7.zip
less: fix a case when regexp matches ""
hush: remove wrong comment, expand another one
Diffstat (limited to 'miscutils/less.c')
-rw-r--r--miscutils/less.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 0529b2047..ecdb9ae60 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -172,16 +172,6 @@ static void set_tty_cooked(void)
172 tcsetattr(kbd_fd, TCSANOW, &term_orig); 172 tcsetattr(kbd_fd, TCSANOW, &term_orig);
173} 173}
174 174
175/* Exit the program gracefully */
176static void less_exit(int code)
177{
178 bb_putchar('\n');
179 set_tty_cooked();
180 if (code < 0)
181 kill_myself_with_sig(- code); /* does not return */
182 exit(code);
183}
184
185/* Move the cursor to a position (x,y), where (0,0) is the 175/* Move the cursor to a position (x,y), where (0,0) is the
186 top-left corner of the console */ 176 top-left corner of the console */
187static void move_cursor(int line, int row) 177static void move_cursor(int line, int row)
@@ -205,6 +195,16 @@ static void print_statusline(const char *str)
205 printf(HIGHLIGHT"%.*s"NORMAL, width - 1, str); 195 printf(HIGHLIGHT"%.*s"NORMAL, width - 1, str);
206} 196}
207 197
198/* Exit the program gracefully */
199static void less_exit(int code)
200{
201 set_tty_cooked();
202 clear_line();
203 if (code < 0)
204 kill_myself_with_sig(- code); /* does not return */
205 exit(code);
206}
207
208#if ENABLE_FEATURE_LESS_REGEXP 208#if ENABLE_FEATURE_LESS_REGEXP
209static void fill_match_lines(unsigned pos); 209static void fill_match_lines(unsigned pos);
210#else 210#else
@@ -538,6 +538,9 @@ static void print_found(const char *line)
538 start: 538 start:
539 /* Most of the time doesn't find the regex, optimize for that */ 539 /* Most of the time doesn't find the regex, optimize for that */
540 match_status = regexec(&pattern, line, 1, &match_structs, eflags); 540 match_status = regexec(&pattern, line, 1, &match_structs, eflags);
541 /* if even "" matches, treat it as "not a match" */
542 if (match_structs.rm_so >= match_structs.rm_eo)
543 match_status = 1;
541 } 544 }
542 545
543 if (!growline) { 546 if (!growline) {