diff options
author | Denys Vlasenko | 2018-02-08 19:39:42 +0100 |
---|---|---|
committer | Denys Vlasenko | 2018-02-08 19:39:42 +0100 |
commit | f786901c4bc2e724221e5c07208c3cd7913cb98c (patch) | |
tree | dddfb251d33f3a37eb2ac520e93a15b1bf99ba73 /shell/hush.c | |
parent | 5807e18f0c4f6fc247103830affcab73ca1ffa37 (diff) | |
download | busybox-f786901c4bc2e724221e5c07208c3cd7913cb98c.zip busybox-f786901c4bc2e724221e5c07208c3cd7913cb98c.tar.gz |
hush: probably fixing a bug in last LINENO fix
I don't have an example of mishandled script, but the logic looked wrong:
it could sometimes treat newlines as if they are spaces.
function old new delta
parse_stream 2788 2787 -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c index f2ffcf5..8f1017e 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -5019,18 +5019,13 @@ static struct pipe *parse_stream(char **pstring, * i.e., at the previous line. * We need to skip all whitespace before newlines. */ - if (ch != '\n') { - /* It was whitespace, but not a newline. - * Eat all whitespace. - */ - for (;;) { - next = i_peek(input); - if (next != ' ' && next != '\t' && next != '\n') - break; /* next char is not ws */ - ch = i_getch(input); - } - /* ch == last eaten whitespace char */ + while (ch != '\n') { + next = i_peek(input); + if (next != ' ' && next != '\t' && next != '\n') + break; /* next char is not ws */ + ch = i_getch(input); } + /* ch == last eaten whitespace char */ #endif if (done_word(&dest, &ctx)) { goto parse_error; |