From f2de7e59db40daf9efde55bba111e9f4a98ef59f Mon Sep 17 00:00:00 2001 From: albert-github Date: Fri, 26 Jun 2020 15:46:00 +0200 Subject: issue #7872 A define containing a doxygen start of comment breaks the parser Not only the preprocessor suffered from the "problem" but also the source code (e.g. with `SOURCE_BROWSER`) gave some strange / missing results. --- src/code.l | 33 ++++++++++++++++++++++----------- src/pre.l | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/code.l b/src/code.l index ddeca01..aadfcf9 100644 --- a/src/code.l +++ b/src/code.l @@ -621,16 +621,22 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" yyextra->code->codify(yytext); BEGIN( SkipCPP ) ; } +\" { + yyextra->code->codify(yytext); + yyextra->lastStringContext=YY_START; + BEGIN( SkipString ) ; + } . { yyextra->code->codify(yytext); } -[^\n\/\\]+ { +[^\n\/\\\"]+ { yyextra->code->codify(yytext); } \\[\r]?\n { codifyLines(yyscanner,yytext); } -"//" { +"//"/[^/!] { + REJECT; yyextra->code->codify(yytext); } "{" { @@ -1971,15 +1977,25 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" yyextra->yyLineNr+=QCString(yytext).contains('\n'); } "*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)? { - yyextra->yyLineNr+=QCString(yytext).contains('\n'); - nextCodeLine(yyscanner); if (yyextra->lastSpecialCContext==SkipCxxComment) { // force end of C++ comment here + yyextra->yyLineNr+=QCString(yytext).contains('\n'); + nextCodeLine(yyscanner); endFontClass(yyscanner); BEGIN( yyextra->lastCContext ) ; } else { + yyextra->yyLineNr+=QCString(yytext).contains('\n'); + if (QCString(yytext).at(strlen(yytext)-1) == '\n') + { + yyextra->yyLineNr--; + unput('\n'); + } + else + { + nextCodeLine(yyscanner); + } BEGIN(yyextra->lastSpecialCContext); } } @@ -2101,14 +2117,9 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" endFontClass(yyscanner); } } -<*>"//"[!/][^\n]*\n { // strip special one-line comment +<*>"//"[!/][^\n]*/\n { // strip special one-line comment if (YY_START==SkipComment || YY_START==SkipString) REJECT; - if (Config_getBool(STRIP_CODE_COMMENTS)) - { - char c[2]; c[0]='\n'; c[1]=0; - codifyLines(yyscanner,c); - } - else + if (!Config_getBool(STRIP_CODE_COMMENTS)) { startFontClass(yyscanner,"comment"); codifyLines(yyscanner,yytext); diff --git a/src/pre.l b/src/pre.l index 4ec76ab..8d773ae 100644 --- a/src/pre.l +++ b/src/pre.l @@ -1632,7 +1632,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) } } "//"[/]? { yyextra->defText += yytext; yyextra->defLitText+=yytext; } -"/*" { yyextra->defText += yytext; yyextra->defLitText+=yytext; } +"/*"[*]? { yyextra->defText += yytext; yyextra->defLitText+=yytext; } \" { yyextra->defText += *yytext; yyextra->defLitText+=yytext; BEGIN(DefineText); -- cgit v0.12