diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-09 16:02:39 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-09 16:02:39 +0000 |
| commit | 3fe4f986a055d0bc942dcda0c2fea3ef68e341d7 (patch) | |
| tree | edb986f2879dd8c71d56b31114c84bec043d2197 | |
| parent | 98a6f56d495698a31909afee0acf36f7c9f1d5ee (diff) | |
| download | busybox-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
| -rw-r--r-- | miscutils/less.c | 23 | ||||
| -rw-r--r-- | shell/hush.c | 5 |
2 files changed, 17 insertions, 11 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 */ | ||
| 176 | static 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 */ |
| 187 | static void move_cursor(int line, int row) | 177 | static 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 */ | ||
| 199 | static 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 |
| 209 | static void fill_match_lines(unsigned pos); | 209 | static 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) { |
diff --git a/shell/hush.c b/shell/hush.c index 9e574c90c..b80468f58 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -3218,7 +3218,6 @@ static int redirect_opt_num(o_string *o) | |||
| 3218 | } | 3218 | } |
| 3219 | 3219 | ||
| 3220 | #if ENABLE_HUSH_TICK | 3220 | #if ENABLE_HUSH_TICK |
| 3221 | /* NB: currently disabled on NOMMU */ | ||
| 3222 | static FILE *generate_stream_from_list(struct pipe *head) | 3221 | static FILE *generate_stream_from_list(struct pipe *head) |
| 3223 | { | 3222 | { |
| 3224 | FILE *pf; | 3223 | FILE *pf; |
| @@ -3229,6 +3228,10 @@ static FILE *generate_stream_from_list(struct pipe *head) | |||
| 3229 | /* By using vfork here, we suspend parent till child exits or execs. | 3228 | /* By using vfork here, we suspend parent till child exits or execs. |
| 3230 | * If child will not do it before it fills the pipe, it can block forever | 3229 | * If child will not do it before it fills the pipe, it can block forever |
| 3231 | * in write(STDOUT_FILENO), and parent (shell) will be also stuck. | 3230 | * in write(STDOUT_FILENO), and parent (shell) will be also stuck. |
| 3231 | * Try this script: | ||
| 3232 | * yes "0123456789012345678901234567890" | dd bs=32 count=64k >TESTFILE | ||
| 3233 | * huge=`cat TESTFILE` # will block here forever | ||
| 3234 | * echo OK | ||
| 3232 | */ | 3235 | */ |
| 3233 | pid = BB_MMU ? fork() : vfork(); | 3236 | pid = BB_MMU ? fork() : vfork(); |
| 3234 | if (pid < 0) | 3237 | if (pid < 0) |
