From 0e85b883e4b66632b352f910c3e1ae13f47cb47b Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 13 Feb 2021 19:36:46 +0100 Subject: Refactoring: replace QRegExp by std::regex in doctokenizer.l --- src/doctokenizer.l | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/doctokenizer.l b/src/doctokenizer.l index a11f2fe..d2ba897 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -26,6 +26,8 @@ #include #include +#include +#include #include #include @@ -513,9 +515,11 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio else { lineCount(yytext,yyleng); - QCString text=yytext; - static QRegExp re("[*+]"); - int listPos = text.findRev(re); + std::string text=yytext; + static std::regex re("[*+][^*+]*$"); // find last + or * + std::smatch match; + std::regex_search(text,match,re); + size_t listPos = match.position(); g_token->isEnumList = FALSE; g_token->id = -1; g_token->indent = computeIndent(yytext,listPos); @@ -529,13 +533,13 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio } else { - QCString text=yytext; - static QRegExp re("[1-9]"); - int digitPos = text.find(re); - int dotPos = text.find('.',digitPos); - g_token->isEnumList = TRUE; - g_token->id = atoi(QCString(yytext).mid(digitPos,dotPos-digitPos)); - g_token->indent = computeIndent(yytext,digitPos); + std::string text=yytext; + static std::regex re("[1-9]+"); + std::smatch match; + std::regex_search(text,match,re); + g_token->isEnumList = true; + g_token->id = std::stoul(match.str()); + g_token->indent = computeIndent(yytext,match.position()); return TK_LISTITEM; } } @@ -556,12 +560,14 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio else { lineCount(yytext,yyleng); - QCString text=extractPartAfterNewLine(yytext); - static QRegExp re("[*+]"); - int markPos = text.findRev(re); + std::string text=extractPartAfterNewLine(yytext).str(); + static std::regex re("[*+][^*+]*$"); // find last + or * + std::smatch match; + std::regex_search(text,match,re); + size_t markPos = match.position(); g_token->isEnumList = FALSE; g_token->id = -1; - g_token->indent = computeIndent(text,markPos); + g_token->indent = computeIndent(text.c_str(),markPos); return TK_LISTITEM; } } @@ -573,13 +579,13 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio else { lineCount(yytext,yyleng); - QCString text=extractPartAfterNewLine(yytext); - static QRegExp re("[1-9]"); - int digitPos = text.find(re); - int dotPos = text.find('.',digitPos); - g_token->isEnumList = TRUE; - g_token->id = atoi(QCString(text).mid(digitPos,dotPos-digitPos)); - g_token->indent = computeIndent(text,digitPos); + std::string text=extractPartAfterNewLine(yytext).str(); + static std::regex re("[1-9]+"); + std::smatch match; + std::regex_search(text,match,re); + g_token->isEnumList = true; + g_token->id = std::stoul(match.str()); + g_token->indent = computeIndent(text.c_str(),match.position()); return TK_LISTITEM; } } -- cgit v0.12