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>
This commit is contained in:
Denys Vlasenko
2018-12-25 23:45:57 +01:00
parent c192b0442b
commit 94576d2b97
2 changed files with 34 additions and 18 deletions

View File

@@ -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) {