From e9da884cc5e87b7a677871d9f46c7fe5377b1d26 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 20 Feb 2023 11:27:42 +0200 Subject: Fix raw string literal lexing bug in cc:lexer (GH issue #268) --- libbuild2/cc/lexer+raw-string-literal.test.testscript | 2 ++ 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 @@ -24,6 +25,7 @@ EOI + 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"()" // // Where 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 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 == '(') -- cgit v1.1