@@ -225,6 +225,8 @@ static QCString stripFuncPtr(const QCString &type);
225225static bool nameIsOperator (QCString &name);
226226void fixArgumentListForJavaScript (ArgumentList &al);
227227static bool startOfRequiresExpression (const QCString &req);
228+ static QCString extractBeginRawStringDelimiter (const char *str);
229+ static QCString extractEndRawStringDelimiter (const char *str);
228230
229231// forward declarations for statefull functions
230232static void initParser (yyscan_t yyscanner);
@@ -3097,25 +3099,24 @@ NONLopt [^\n]*
30973099 }
30983100 else
30993101 {
3100- QCString text=yytext;
3101- yyextra->current->initializer << text;
3102- int i=text.find(' " ');
3103- yyextra->delimiter = yytext+i+1;
3104- yyextra->delimiter=yyextra->delimiter.left(yyextra->delimiter.length()-1);
3102+ yyextra->current->initializer << yytext;
3103+ yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
31053104 yyextra->lastRawStringContext = YY_START;
31063105 yyextra->pCopyRawGString = &yyextra->current->initializer;
31073106 BEGIN(RawGString);
31083107 //printf("RawGString delimiter=' %s' \n ",qPrint(delimiter));
31093108 }
31103109 }
31113110<RawGString>{RAWEND} {
3112- *yyextra->pCopyRawGString << yytext;
3113- QCString delimiter = yytext+1;
3114- delimiter=delimiter.left(delimiter.length()-1);
3115- if (delimiter==yyextra->delimiter)
3111+ if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
31163112 {
3113+ *yyextra->pCopyRawGString << yytext;
31173114 BEGIN(yyextra->lastRawStringContext);
31183115 }
3116+ else
3117+ {
3118+ REJECT;
3119+ }
31193120 }
31203121<RawGString>[^)\n ]+ {
31213122 *yyextra->pCopyRawGString << yytext;
@@ -3130,9 +3131,7 @@ NONLopt [^\n]*
31303131<RawString>{RAWEND} {
31313132 *yyextra->pCopyRawString+=yytext;
31323133 yyextra->fullArgString+=yytext;
3133- QCString delimiter = yytext+1;
3134- delimiter=delimiter.left(delimiter.length()-1);
3135- if (delimiter==yyextra->delimiter)
3134+ if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
31363135 {
31373136 BEGIN(yyextra->lastRawStringContext);
31383137 }
@@ -3472,9 +3471,16 @@ NONLopt [^\n]*
34723471 yyextra->pSkipVerbString=yyextra->pCopyRoundGString;
34733472 BEGIN(SkipVerbString);
34743473 }
3475- <GCopyRound>[^" '()\n \/,]+ {
3474+ <GCopyRound>[^"' ()\n\/,R ]+ { // R because of raw string start
34763475 *yyextra->pCopyRoundGString << yytext;
34773476 }
3477+ <GCopyRound>{RAWBEGIN} {
3478+ *yyextra->pCopyRoundGString << yytext;
3479+ yyextra->delimiter = extractBeginRawStringDelimiter (yytext);
3480+ yyextra->lastRawStringContext = YY_START;
3481+ yyextra->pCopyRawGString = yyextra->pCopyRoundGString ;
3482+ BEGIN (RawGString);
3483+ }
34783484<GCopyRound>. {
34793485 *yyextra->pCopyRoundGString << *yytext;
34803486 }
@@ -4102,8 +4108,8 @@ NONLopt [^\n]*
41024108 yyextra->lastSquareContext = YY_START;
41034109 BEGIN(SkipSquare);
41044110 }
4105- <ReadBody,ReadNSBody,ReadBodyIntf>[^\r\n \# {}"@' /<\\\$]* { yyextra->current ->program << yytext ; }
4106- <ReadBody,ReadNSBody,ReadBodyIntf>{CPPC}.* { yyextra->current ->program << yytext ; }
4111+ <ReadBody,ReadNSBody,ReadBodyIntf>[^\r\n \# {}"@' /<\\\$R ]* { yyextra->current ->program << yytext ; } // R because of raw string start
4112+ <ReadBody,ReadNSBody,ReadBodyIntf>{CPPC}.* { yyextra->current ->program << yytext ; }
41074113<ReadBody,ReadNSBody,ReadBodyIntf>" #" .* { if (!yyextra->insidePHP )
41084114 REJECT;
41094115 // append PHP comment.
@@ -4161,6 +4167,13 @@ NONLopt [^\n]*
41614167 REJECT;
41624168 }
41634169 }
4170+ <ReadBody,ReadNSBody,ReadBodyIntf>{RAWBEGIN} {
4171+ yyextra->current->program << yytext;
4172+ yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
4173+ yyextra->lastRawStringContext = YY_START;
4174+ yyextra->pCopyRawGString = &yyextra->current->program;
4175+ BEGIN(RawGString);
4176+ }
41644177<ReadBody,ReadNSBody,ReadBodyIntf>\" { yyextra->current->program << yytext ;
41654178 yyextra->pCopyQuotedGString = &yyextra->current->program;
41664179 yyextra->lastStringContext=YY_START;
@@ -4778,8 +4791,7 @@ NONLopt [^\n]*
47784791 lineCount(yyscanner);
47794792 }
47804793<ReadFuncArgType,CopyArgRound,CopyArgSquare,CopyArgSharp,ReadTempArgs>{RAWBEGIN} {
4781- yyextra->delimiter = yytext+2;
4782- yyextra->delimiter=yyextra->delimiter.left(yyextra->delimiter.length()-1);
4794+ yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
47834795 yyextra->lastRawStringContext = YY_START;
47844796 yyextra->pCopyRawString = yyextra->copyArgString;
47854797 *yyextra->pCopyRawString+=yytext;
@@ -5691,9 +5703,7 @@ NONLopt [^\n]*
56915703 }
56925704 }
56935705<SkipCurly,SkipCurlyCpp>{B}*{RAWBEGIN} {
5694- QCString raw=QCString(yytext).stripWhiteSpace();
5695- yyextra->delimiter = raw.mid(2);
5696- yyextra->delimiter=yyextra->delimiter.left(yyextra->delimiter.length()-1);
5706+ yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
56975707 yyextra->lastRawStringContext = YY_START;
56985708 yyextra->dummyRawString.clear();
56995709 yyextra->pCopyRawString = &yyextra->dummyRawString;
@@ -7560,6 +7570,20 @@ static inline int computeIndent(const char *s,int startIndent)
75607570 return col;
75617571}
75627572
7573+ static QCString extractBeginRawStringDelimiter(const char *rawStart)
7574+ {
7575+ QCString text=rawStart;
7576+ int i = text.find('" ' );
7577+ assert(i!=-1);
7578+ return text.mid(i+1,text.length()-i-2); // text=...R"xyz( -> delimiter=xyz
7579+ }
7580+
7581+ static QCString extractEndRawStringDelimiter(const char *rawEnd)
7582+ {
7583+ QCString text=rawEnd;
7584+ return text.mid(1,text.length()-2); // text=)xyz" -> delimiter=xyz
7585+ }
7586+
75637587static inline void initMethodProtection(yyscan_t yyscanner,Protection prot)
75647588{
75657589 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
0 commit comments