Skip to content

Fix handling of escaped backslashes in expanded string (#464) #481

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
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
4 changes: 2 additions & 2 deletions source/lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ auto expand_string_literal(
// Then put interpolated chunk into ret
auto chunk = std::string{text.substr(open, pos - open)};
{ // unescape chunk string
auto last_it = std::copy_if(std::begin(chunk), std::end(chunk), std::begin(chunk), [escape = false](const auto& e) mutable {
auto last_it = std::remove_if(std::begin(chunk), std::end(chunk), [escape = false](const auto& e) mutable {
escape = !escape && e == '\\';
return !escape;
return escape;
});
chunk.erase(last_it, std::end(chunk));
}
Expand Down