From f8ce2e4edbf986248b7382a702d982173c2f41d0 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Tue, 24 Sep 2019 21:31:40 +0200 Subject: issue #7265: Double quote character in C++ raw string literal causes Doxygen to process the string contents --- src/pre.l | 25 +++++++++++++++++++++++++ src/scanner.l | 11 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/pre.l b/src/pre.l index c413a11..cebc98f 100644 --- a/src/pre.l +++ b/src/pre.l @@ -385,6 +385,7 @@ static bool g_isSource; static bool g_lexInit = FALSE; static int g_fenceSize = 0; static bool g_ccomment; +static QCString g_delimiter; //DefineDict* getGlobalDefineDict() //{ @@ -1768,6 +1769,8 @@ static int yyread(char *buf,int max_size) ID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* B [ \t] BN [ \t\r\n] +RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"(" +RAWEND ")"[^ \t\(\)\\]{0,16}\" CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) %option noyywrap @@ -1782,6 +1785,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) %x CopyStringCs %x CopyStringFtn %x CopyStringFtnDouble +%x CopyRawString %x Include %x IncludeID %x EndImport @@ -1868,6 +1872,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) g_yyLineNr+=text.contains('\n'); outputArray(yytext,(int)yyleng); } +{RAWBEGIN} { + g_delimiter = yytext+2; + g_delimiter=g_delimiter.left(g_delimiter.length()-1); + outputArray(yytext,(int)yyleng); + BEGIN(CopyRawString); + } "{" { // count brackets inside the main file if (g_includeStack.isEmpty()) { @@ -1945,6 +1955,21 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) outputChar(*yytext); BEGIN( CopyLine ); } +{RAWEND} { + outputArray(yytext,(int)yyleng); + QCString delimiter = yytext+1; + delimiter=delimiter.left(delimiter.length()-1); + if (delimiter==g_delimiter) + { + BEGIN( CopyLine ); + } + } +[^)]+ { + outputArray(yytext,(int)yyleng); + } +. { + outputChar(*yytext); + } {ID}/{BN}{0,80}"(" { g_expectGuard = FALSE; Define *def=0; diff --git a/src/scanner.l b/src/scanner.l index f6ffdff..07d5c71 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -142,6 +142,7 @@ static int lastCopyArgStringContext; static int lastCopyArgContext; static QCString *copyArgString; static QCString fullArgString; +static QCString dummyRawString; static ArgumentList *currentArgumentList; static char lastCopyArgChar; @@ -5398,6 +5399,16 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN(HereDoc); } } +{B}*{RAWBEGIN} { + QCString raw=QCString(yytext).stripWhiteSpace(); + g_delimiter = raw.data()+2; + g_delimiter=g_delimiter.left(g_delimiter.length()-1); + lastRawStringContext = YY_START; + dummyRawString.resize(0); + pCopyRawString = &dummyRawString; + *pCopyRawString+=yytext; + BEGIN(RawString); + } [^\n#"'@\\/{}<]+ { lineCount(); // for g_column updates //addToBody(yytext); -- cgit v0.12