diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-01-17 10:46:56 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2021-01-22 20:45:21 (GMT) |
commit | d0b76baca69b5a08a5cf3f756b365f1350f88271 (patch) | |
tree | 121170a90fe382c43d14204676ae1425b9fb41e8 /src | |
parent | 40372ae052d73187b26e19f39bd2727a6f413630 (diff) | |
download | Doxygen-d0b76baca69b5a08a5cf3f756b365f1350f88271.zip Doxygen-d0b76baca69b5a08a5cf3f756b365f1350f88271.tar.gz Doxygen-d0b76baca69b5a08a5cf3f756b365f1350f88271.tar.bz2 |
Refactoring: modernize condStack
Diffstat (limited to 'src')
-rw-r--r-- | src/commentcnv.l | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/commentcnv.l b/src/commentcnv.l index f9f0eb3..817feb3 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -27,8 +27,8 @@ #include <stdio.h> #include <stdlib.h> +#include <stack> -#include <qstack.h> #include <qregexp.h> #include <qtextstream.h> #include <qglobal.h> @@ -80,7 +80,7 @@ struct commentcnvYY_state QCString fileName; int lineNr = 0; int condCtx = 0; - QStack<CondCtx> condStack; + std::stack<CondCtx> condStack; std::stack<int> commentStack; QCString blockName; int lastCommentContext = 0; @@ -1029,7 +1029,7 @@ static void startCondSection(yyscan_t yyscanner,const char *sectId) //printf("startCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count()); CondParser prs; bool expResult = prs.parse(yyextra->fileName,yyextra->lineNr,sectId); - yyextra->condStack.push(new CondCtx(yyextra->lineNr,sectId,yyextra->skip)); + yyextra->condStack.push(CondCtx(yyextra->lineNr,sectId,yyextra->skip)); if (!expResult) // not enabled { yyextra->skip=TRUE; @@ -1039,15 +1039,16 @@ static void startCondSection(yyscan_t yyscanner,const char *sectId) static void endCondSection(yyscan_t yyscanner) { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; - if (yyextra->condStack.isEmpty()) + if (yyextra->condStack.empty()) { warn(yyextra->fileName,yyextra->lineNr,"Found \\endcond command without matching \\cond"); yyextra->skip=FALSE; } else { - CondCtx *ctx = yyextra->condStack.pop(); - yyextra->skip=ctx->skip; + const CondCtx &ctx = yyextra->condStack.top(); + yyextra->skip=ctx.skip; + yyextra->condStack.pop(); } //printf("endCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count()); } @@ -1151,8 +1152,7 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName) yyextra->lang = getLanguageFromFileName(fileName); yyextra->pythonDocString = FALSE; yyextra->lineNr = 1; - yyextra->condStack.clear(); - yyextra->condStack.setAutoDelete(TRUE); + while (!yyextra->condStack.empty()) yyextra->condStack.pop(); clearCommentStack(yyscanner); yyextra->vhdl = FALSE; @@ -1175,13 +1175,14 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName) BEGIN(Scan); } yylex(yyscanner); - while (!yyextra->condStack.isEmpty()) + while (!yyextra->condStack.empty()) { - CondCtx *ctx = yyextra->condStack.pop(); + const CondCtx &ctx = yyextra->condStack.top(); QCString sectionInfo = " "; - if (ctx->sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx->sectionId.stripWhiteSpace().data()); - warn(yyextra->fileName,ctx->lineNr,"Conditional section%sdoes not have " + if (ctx.sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx.sectionId.stripWhiteSpace().data()); + warn(yyextra->fileName,ctx.lineNr,"Conditional section%sdoes not have " "a corresponding \\endcond command within this file.",sectionInfo.data()); + yyextra->condStack.pop(); } if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt_Markdown && yyextra->lang!=SrcLangExt_Fortran) { |