diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-02-20 11:27:42 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-02-20 11:27:42 +0200 |
commit | e9da884cc5e87b7a677871d9f46c7fe5377b1d26 (patch) | |
tree | 78f124bb7ca9945d87b131199e96a6857255b2d0 /libbuild2 | |
parent | 01665e5501954961b6f72ce50d2fc3cbfadcddf6 (diff) |
Fix raw string literal lexing bug in cc:lexer (GH issue #268)
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/cc/lexer+raw-string-literal.test.testscript | 2 | ||||
-rw-r--r-- | libbuild2/cc/lexer.cxx | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/libbuild2/cc/lexer+raw-string-literal.test.testscript b/libbuild2/cc/lexer+raw-string-literal.test.testscript index bca489a..a6455eb 100644 --- a/libbuild2/cc/lexer+raw-string-literal.test.testscript +++ b/libbuild2/cc/lexer+raw-string-literal.test.testscript @@ -16,6 +16,7 @@ R"X(a b)X" R"X(a\ b)X" +R""(a)"" EOI <string literal> <string literal> @@ -24,6 +25,7 @@ EOI <string literal> <string literal> <string literal> +<string literal> EOO : prefix diff --git a/libbuild2/cc/lexer.cxx b/libbuild2/cc/lexer.cxx index beeb970..467c0b1 100644 --- a/libbuild2/cc/lexer.cxx +++ b/libbuild2/cc/lexer.cxx @@ -734,8 +734,8 @@ namespace build2 // R"<delimiter>(<raw_characters>)<delimiter>" // // Where <delimiter> is a potentially-empty character sequence made of - // any source character but parentheses, backslash and spaces. It can be - // at most 16 characters long. + // any source character but parentheses, backslash, and spaces (in + // particular, it can be `"`). It can be at most 16 characters long. // // Note that the <raw_characters> are not processed in any way, not even // for line continuations. @@ -750,7 +750,7 @@ namespace build2 { c = geth (); - if (eos (c) || c == '\"' || c == ')' || c == '\\' || c == ' ') + if (eos (c) || c == ')' || c == '\\' || c == ' ') fail (l) << "invalid raw string literal"; if (c == '(') |