@@ -81,6 +81,7 @@ struct commentcnv_FileState
8181 int oldFileBufPos = 0 ;
8282 int oldIncludeCtx = 0 ;
8383 int oldRaiseLvl = 0 ;
84+ QCString oldRaiseLbl;
8485};
8586
8687struct commentcnvYY_state
@@ -96,7 +97,9 @@ struct commentcnvYY_state
9697 int readLineCtx = 0 ;
9798 int includeCtx = 0 ;
9899 int raiseLevel = 0 ;
100+ QCString raiseLabel;
99101 int raiseIncrement = 0 ;
102+ QCString incrementLabel;
100103 bool skip = FALSE ;
101104 QCString fileName;
102105 int lineNr = 0 ;
@@ -144,7 +147,7 @@ static void replaceComment(yyscan_t yyscanner,int offset);
144147static void clearCommentStack (yyscan_t yyscanner);
145148static bool readIncludeFile (yyscan_t yyscanner,const QCString &inc,const QCString &blockId);
146149static void insertCommentStart (yyscan_t yyscanner);
147- static void parseIncludeOptions (yyscan_t yyscanner,std::string_view s);
150+ static bool parseIncludeOptions (yyscan_t yyscanner,std::string_view s);
148151
149152#undef YY_INPUT
150153#define YY_INPUT (buf,result,max_size ) result=yyread(yyscanner,buf,max_size);
@@ -214,7 +217,7 @@ FILEMASK {VFILEMASK}|{HFILEMASK}
214217B [ \t ]
215218ID [$a-z_A-Z\x80 -\xFF ][$a-z_A-Z0-9\x80 -\xFF ]*
216219
217- OPTS (","{B}*{ID}{B}*("=" {B}*({ID}|[0-9]*){B}*)?) *
220+ OPTS "{"[^}]*"}" {B}*
218221
219222 //- end: NUMBER ---------------------------------------------------------------------------
220223
@@ -1033,7 +1036,7 @@ SLASHopt [/]*
10331036 copyToOutput (yyscanner,yytext,yyleng);
10341037 }
10351038
1036- <CComment,ReadLine,IncludeFile>{B}{B}{B}{B}[\\@](" include{ " {B}* " doc " {B}*{ OPTS}" } " |" includedoc" ) { // Markdown code section
1039+ <CComment,ReadLine,IncludeFile>{B}{B}{B}{B}[\\@](" include" { OPTS}|" includedoc" {OPTS}* ) { // Markdown code section
10371040 if (Config_getBool (MARKDOWN_SUPPORT))
10381041 {
10391042 copyToOutput (yyscanner,yytext,yyleng);
@@ -1043,7 +1046,7 @@ SLASHopt [/]*
10431046 REJECT;
10441047 }
10451048 }
1046- <CComment,ReadLine,IncludeFile>{B}{B}{B}{B}[\\@](" snippet{ " {B}* " doc " {B}*{ OPTS}" } " |" snippetdoc" ) { // Markdown code section
1049+ <CComment,ReadLine,IncludeFile>{B}{B}{B}{B}[\\@](" snippet" { OPTS}|" snippetdoc" {OPTS}* ) { // Markdown code section
10471050 if (Config_getBool (MARKDOWN_SUPPORT))
10481051 {
10491052 copyToOutput (yyscanner,yytext,yyleng);
@@ -1053,10 +1056,10 @@ SLASHopt [/]*
10531056 REJECT;
10541057 }
10551058 }
1056- <CComment,ReadLine,IncludeFile>[\\@](" include{" {B}*" doc" {B}*{OPTS}" }" |" includedoc" ) {
1059+ <CComment,ReadLine,IncludeFile>[\\@](" include" {OPTS}|" includedoc" {OPTS}*) {
1060+ if (!parseIncludeOptions (yyscanner,std::string_view{yytext,static_cast <size_t >(yyleng)})) REJECT;
10571061 yyextra->includeCtx = YY_START;
10581062 yyextra->firstIncludeLine = true ;
1059- parseIncludeOptions (yyscanner,std::string_view{yytext,static_cast <size_t >(yyleng)});
10601063 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx ==ReadLine || yyextra->includeCtx ==IncludeFile))
10611064 {
10621065 if (yyextra->includeCtx ==ReadLine)
@@ -1067,10 +1070,10 @@ SLASHopt [/]*
10671070 }
10681071 BEGIN (IncludeDoc);
10691072 }
1070- <CComment,ReadLine,IncludeFile>[\\@](" snippet{" {B}*" doc" {B}*{OPTS}" }" |" snippetdoc" ) {
1073+ <CComment,ReadLine,IncludeFile>[\\@](" snippet" {OPTS}|" snippetdoc" {OPTS}*) {
1074+ if (!parseIncludeOptions (yyscanner,std::string_view{yytext,static_cast <size_t >(yyleng)})) REJECT;
10711075 yyextra->includeCtx = YY_START;
10721076 yyextra->firstIncludeLine = true ;
1073- parseIncludeOptions (yyscanner,std::string_view{yytext,static_cast <size_t >(yyleng)});
10741077 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx ==ReadLine || yyextra->includeCtx ==IncludeFile))
10751078 {
10761079 if (yyextra->includeCtx ==ReadLine)
@@ -1283,11 +1286,12 @@ SLASHopt [/]*
12831286 yyextra->inBufPos = fs->oldFileBufPos ;
12841287 yyextra->includeCtx = fs->oldIncludeCtx ;
12851288 QCString lineStr= " \\ ilinebr \\ ifile \" " +yyextra->fileName +" \" \\ iline " +QCString ().setNum (yyextra->lineNr )+" " ;
1286- if (fs->oldRaiseLvl !=yyextra->raiseLevel )
1289+ if (fs->oldRaiseLvl !=yyextra->raiseLevel || fs-> oldRaiseLbl !=yyextra-> raiseLabel )
12871290 {
1288- lineStr+=std::string ( " \\ iraise " ) + std::to_string (fs->oldRaiseLvl );
1291+ lineStr+=" \\ iraise " + std::to_string (fs->oldRaiseLvl ) + " \" " + fs-> oldRaiseLbl + " \" " ;
12891292 }
12901293 yyextra->raiseLevel = fs->oldRaiseLvl ;
1294+ yyextra->raiseLabel = fs->oldRaiseLbl ;
12911295 copyToOutput (yyscanner,lineStr.view ());
12921296 yyextra->includeStack .pop_back ();
12931297 // printf("<<EOF>> switch back to %s line %d inbufPos=%d outbufPos=%d\n",
@@ -1299,22 +1303,70 @@ SLASHopt [/]*
12991303 */
13001304%%
13011305
1302- static void parseIncludeOptions (yyscan_t yyscanner,std::string_view s)
1306+ static bool parseIncludeOptions (yyscan_t yyscanner,std::string_view s)
13031307{
13041308 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1309+
1310+ QCString fullMatch = QCString(yytext);
13051311 // printf("parseIncludeOptions=%s\n",qPrint(QCString(s)));
1306- static const reg::Ex re (R"( ,\s*raise\s*=\s*(\d+))" );
1307- reg::Match match;
1308- if (reg::search(s,match,re))
1312+ int idx = fullMatch.find('{' );
1313+ int idxEnd = fullMatch.find("}",idx+1);
1314+ QCString cmdName;
1315+ StringVector optList;
1316+ if (idx == -1) // no options
1317+ {
1318+ cmdName = QCString(yytext).stripWhiteSpace().mid(1); // to remove {CMD}
1319+ }
1320+ else // options present
1321+ {
1322+ cmdName = fullMatch.left(idx).stripWhiteSpace().mid(1); // to remove {CMD}
1323+ QCString optStr = fullMatch.mid(idx+1,idxEnd-idx-1).stripWhiteSpace();
1324+ optList = split(optStr.str(),",");
1325+ }
1326+ bool isDoc = false;
1327+ if (cmdName=="includedoc" || cmdName=="snippetdoc") isDoc = true;
1328+
1329+ for (const auto &opt : optList)
13091330 {
1310- yyextra->raiseIncrement = atoi (match[1 ].str ().c_str ());
1311- if (yyextra->raiseLevel +yyextra->raiseIncrement >=Section::MaxLevel) // check range
1331+ QCString locOpt = QCString(opt);
1332+ locOpt = locOpt.stripWhiteSpace();
1333+ if (locOpt=="doc")
13121334 {
1313- warn (yyextra->fileName ,yyextra->lineNr ," Raising section level from %d to %d, exceeds allowed range [0-%d], adjusting" ,
1314- yyextra->raiseLevel ,yyextra->raiseLevel +yyextra->raiseIncrement ,Section::MaxLevel-1 );
1315- yyextra->raiseIncrement = std::max (0 ,Section::MaxLevel-1 -yyextra->raiseLevel );
1335+ isDoc = true;
1336+ }
1337+ else
1338+ {
1339+ int posEqual = locOpt.find(' =' );
1340+ if (posEqual == -1)
1341+ {
1342+ isDoc = false;
1343+ break;
1344+ }
1345+ QCString option = locOpt.left(posEqual);
1346+ QCString value = locOpt.mid(posEqual+1);
1347+ if (option == "raise")
1348+ {
1349+ yyextra->raiseIncrement = atoi(value.data());
1350+ if (yyextra->raiseLevel+yyextra->raiseIncrement>=Section::MaxLevel) // check range
1351+ {
1352+ warn(yyextra->fileName,yyextra->lineNr,"Raising section level from %d to %d, exceeds allowed range [0-%d], adjusting",
1353+ yyextra->raiseLevel,yyextra->raiseLevel+yyextra->raiseIncrement,Section::MaxLevel-1);
1354+ yyextra->raiseIncrement = std::max(0,Section::MaxLevel-1-yyextra->raiseLevel);
1355+ }
1356+ }
1357+ else if (option == "label")
1358+ {
1359+ yyextra->incrementLabel = value;
1360+ }
1361+ else
1362+ {
1363+ isDoc = false;
1364+ break;
1365+ }
13161366 }
13171367 }
1368+
1369+ return isDoc;
13181370}
13191371
13201372
@@ -1633,11 +1685,13 @@ static bool readIncludeFile(yyscan_t yyscanner,const QCString &inc,const QCStrin
16331685 }
16341686 }
16351687 int oldRaiseLevel = yyextra->raiseLevel;
1688+ QCString oldRaiseLabel = yyextra->raiseLabel;
16361689 yyextra->raiseLevel+=yyextra->raiseIncrement;
1690+ yyextra->raiseLabel+=yyextra->incrementLabel;
16371691 QCString lineStr=" \\ ilinebr \\ ifile \" "+absFileName+"\" \\ iline " + std::to_string(lineNr);
1638- if (yyextra->raiseLevel >0 )
1692+ if (yyextra->raiseLevel>0 || !yyextra->raiseLabel.isEmpty() )
16391693 {
1640- lineStr+=" \\ iraise " + std::to_string (yyextra->raiseLevel );
1694+ lineStr+=" \\ iraise " + std::to_string(yyextra->raiseLevel) + " \" " + yyextra->raiseLabel + " \" " ;
16411695 }
16421696 lineStr+=" \\ ilinebr ";
16431697 copyToOutput(yyscanner,lineStr.view());
@@ -1651,6 +1705,7 @@ static bool readIncludeFile(yyscan_t yyscanner,const QCString &inc,const QCStrin
16511705 fs->oldFileBufPos = yyextra->inBufPos;
16521706 fs->oldIncludeCtx = yyextra->includeCtx;
16531707 fs->oldRaiseLvl = oldRaiseLevel;
1708+ fs->oldRaiseLbl = oldRaiseLabel;
16541709 fs->blockId = blockId;
16551710 yy_switch_to_buffer(yy_create_buffer(0, YY_BUF_SIZE, yyscanner),yyscanner);
16561711 yyextra->fileName = absFileName;
@@ -1803,7 +1858,9 @@ void convertCppComments(const std::string &inBuf,std::string &outBuf,const std::
18031858 yyextra->pythonDocString = FALSE;
18041859 yyextra->lineNr = 1;
18051860 yyextra->raiseLevel = 0;
1861+ yyextra->raiseLabel = "";
18061862 yyextra->raiseIncrement = 0;
1863+ yyextra->incrementLabel = "";
18071864 yyextra->insertCppCommentMarker=false;
18081865 yyextra->expandedAliases.clear();
18091866 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
0 commit comments