Skip to content

FIX: parsing of string literals that contains //, closes #442 #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,20 @@ auto process_cpp2_line(
auto found_end = false;

auto prev = ' ';
auto in_string_literal = false;

for (auto i = colno_t{0}; i < ssize(line); ++i) {

if (in_comment) {
switch (line[i]) {
break;case '/': if (prev == '*') { in_comment = false; }
break;default: ;
}
} else if (in_string_literal) {
switch (line[i]) {
break;case '"': if (prev != '\\') { in_string_literal = false; }
break;default: ;
}
}

else {
Expand Down Expand Up @@ -732,6 +739,9 @@ auto process_cpp2_line(
break;case '/':
if (prev == '/') { in_comment = false; return false; }

break;case '"':
if (prev != '\\') { in_string_literal = true; }

break;default: ;
}
}
Expand Down