diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-25 23:45:57 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-25 23:45:57 +0100 |
commit | 94576d2b972b3bd136fbe8057c95690ae36ea8c9 (patch) | |
tree | cc1b99c8e3fb95448b7595fea6b141516894cf40 /miscutils/bc.c | |
parent | c192b0442b0b3f50d4fbb34322e07f0ff3c5aecd (diff) | |
download | busybox-w32-94576d2b972b3bd136fbe8057c95690ae36ea8c9.tar.gz busybox-w32-94576d2b972b3bd136fbe8057c95690ae36ea8c9.tar.bz2 busybox-w32-94576d2b972b3bd136fbe8057c95690ae36ea8c9.zip |
bc: fix interactive handling of comments in strings and quotes in comments
function old new delta
zbc_lex_next 1965 1979 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r-- | miscutils/bc.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 809b4bfc4..9d04ddea3 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -2910,25 +2910,29 @@ static bool bc_lex_more_input(void) | |||
2910 | string = G.input_buffer.v + prevlen; | 2910 | string = G.input_buffer.v + prevlen; |
2911 | while (*string) { | 2911 | while (*string) { |
2912 | char c = *string; | 2912 | char c = *string; |
2913 | if (string == G.input_buffer.v || string[-1] != '\\') { | 2913 | if (!comment) { |
2914 | if (IS_BC) | 2914 | if (string == G.input_buffer.v || string[-1] != '\\') { |
2915 | str ^= (c == '"'); | 2915 | if (IS_BC) |
2916 | else { | 2916 | str ^= (c == '"'); |
2917 | if (c == ']') | 2917 | else { |
2918 | str -= 1; | 2918 | if (c == ']') |
2919 | else if (c == '[') | 2919 | str -= 1; |
2920 | str += 1; | 2920 | else if (c == '[') |
2921 | str += 1; | ||
2922 | } | ||
2921 | } | 2923 | } |
2922 | } | 2924 | } |
2923 | string++; | 2925 | string++; |
2924 | if (c == '/' && *string == '*') { | 2926 | if (!str) { |
2925 | comment = true; | 2927 | if (c == '/' && *string == '*') { |
2926 | string++; | 2928 | comment = true; |
2927 | continue; | 2929 | string++; |
2928 | } | 2930 | continue; |
2929 | if (c == '*' && *string == '/') { | 2931 | } |
2930 | comment = false; | 2932 | if (c == '*' && *string == '/') { |
2931 | string++; | 2933 | comment = false; |
2934 | string++; | ||
2935 | } | ||
2932 | } | 2936 | } |
2933 | } | 2937 | } |
2934 | if (str != 0 || comment) { | 2938 | if (str != 0 || comment) { |