summaryrefslogtreecommitdiffstats
path: root/src/doctokenizer.l
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-01-17 10:32:07 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-01-22 20:45:21 (GMT)
commit17a3590857e9b12e3b978407a6e10bfa8be59926 (patch)
treeec6c80137440986a47dcc74bfad2c0951c5c3e25 /src/doctokenizer.l
parent5b01aaa8f8004175cf5e4ebbced5e9a96cd0bdcd (diff)
downloadDoxygen-17a3590857e9b12e3b978407a6e10bfa8be59926.zip
Doxygen-17a3590857e9b12e3b978407a6e10bfa8be59926.tar.gz
Doxygen-17a3590857e9b12e3b978407a6e10bfa8be59926.tar.bz2
Refactoring: modernize g_lexerStack
Diffstat (limited to 'src/doctokenizer.l')
-rw-r--r--src/doctokenizer.l23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/doctokenizer.l b/src/doctokenizer.l
index c9fe84f..983b5fa 100644
--- a/src/doctokenizer.l
+++ b/src/doctokenizer.l
@@ -25,10 +25,10 @@
%{
#include <ctype.h>
+#include <stack>
#include <qfile.h>
#include <qstring.h>
-#include <qstack.h>
#include <qdict.h>
#include <qregexp.h>
@@ -72,6 +72,8 @@ static int g_autoListLevel;
struct DocLexerContext
{
+ DocLexerContext(TokenInfo *tk,int r,int lvl,yy_size_t pos,const char *s,YY_BUFFER_STATE bs)
+ : token(tk), rule(r), autoListLevel(lvl), inputPos(pos), inputString(s), state(bs) {}
TokenInfo *token;
int rule;
int autoListLevel;
@@ -80,7 +82,7 @@ struct DocLexerContext
YY_BUFFER_STATE state;
};
-static QStack<DocLexerContext> g_lexerStack;
+static std::stack< std::unique_ptr<DocLexerContext> > g_lexerStack;
static int g_yyLineNr = 0;
@@ -94,28 +96,23 @@ static const char *stateToString(int state);
void doctokenizerYYpushContext()
{
- DocLexerContext *ctx = new DocLexerContext;
- ctx->rule = YY_START;
- ctx->autoListLevel = g_autoListLevel;
- ctx->token = g_token;
- ctx->inputPos = g_inputPos;
- ctx->inputString = g_inputString;
- ctx->state = YY_CURRENT_BUFFER;
- g_lexerStack.push(ctx);
+ g_lexerStack.push(
+ std::make_unique<DocLexerContext>(
+ g_token,YY_START,g_autoListLevel,g_inputPos,g_inputString,YY_CURRENT_BUFFER));
yy_switch_to_buffer(yy_create_buffer(doctokenizerYYin, YY_BUF_SIZE));
}
bool doctokenizerYYpopContext()
{
- if (g_lexerStack.isEmpty()) return FALSE;
- DocLexerContext *ctx = g_lexerStack.pop();
+ if (g_lexerStack.empty()) return FALSE;
+ const auto &ctx = g_lexerStack.top();
g_autoListLevel = ctx->autoListLevel;
g_inputPos = ctx->inputPos;
g_inputString = ctx->inputString;
yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer(ctx->state);
BEGIN(ctx->rule);
- delete ctx;
+ g_lexerStack.pop();
return TRUE;
}