summaryrefslogtreecommitdiffhomepage
path: root/miscutils/bc.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-25 23:45:57 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-25 23:45:57 +0100
commit94576d2b972b3bd136fbe8057c95690ae36ea8c9 (patch)
treecc1b99c8e3fb95448b7595fea6b141516894cf40 /miscutils/bc.c
parentc192b0442b0b3f50d4fbb34322e07f0ff3c5aecd (diff)
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.c36
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)
string = G.input_buffer.v + prevlen;
while (*string) {
char c = *string;
- if (string == G.input_buffer.v || string[-1] != '\\') {
- if (IS_BC)
- str ^= (c == '"');
- else {
- if (c == ']')
- str -= 1;
- else if (c == '[')
- str += 1;
+ if (!comment) {
+ if (string == G.input_buffer.v || string[-1] != '\\') {
+ if (IS_BC)
+ str ^= (c == '"');
+ else {
+ if (c == ']')
+ str -= 1;
+ else if (c == '[')
+ str += 1;
+ }
}
}
string++;
- if (c == '/' && *string == '*') {
- comment = true;
- string++;
- continue;
- }
- if (c == '*' && *string == '/') {
- comment = false;
- string++;
+ if (!str) {
+ if (c == '/' && *string == '*') {
+ comment = true;
+ string++;
+ continue;
+ }
+ if (c == '*' && *string == '/') {
+ comment = false;
+ string++;
+ }
}
}
if (str != 0 || comment) {