summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-02-18 20:15:21 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-02-20 19:17:51 (GMT)
commitdfa3a285c140f57dfa08f4465ab1432853e92551 (patch)
tree29535e38eac9a054f7f4d88437d2d584d2b8b2b3 /src
parent51144470806ec4d17c3e8f2178718ca9d1e11e80 (diff)
downloadDoxygen-dfa3a285c140f57dfa08f4465ab1432853e92551.zip
Doxygen-dfa3a285c140f57dfa08f4465ab1432853e92551.tar.gz
Doxygen-dfa3a285c140f57dfa08f4465ab1432853e92551.tar.bz2
Refactoring: replace QRegExp by std::regex in vhdlcode.l
Diffstat (limited to 'src')
-rw-r--r--src/util.cpp39
-rw-r--r--src/util.h5
-rw-r--r--src/vhdlcode.l35
3 files changed, 64 insertions, 15 deletions
diff --git a/src/util.cpp b/src/util.cpp
index e8fcab9..36866dd 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -7485,3 +7485,42 @@ QCString removeEmptyLines(const QCString &s)
//printf("removeEmptyLines(%s)=%s\n",s.data(),out.data());
return out.data();
}
+
+/// split input string \a s by string delimiter \a delimiter.
+/// returns a vector of non-empty strings that are between the delimiters
+StringVector split(const std::string &s,const std::string &delimiter)
+{
+ StringVector result;
+ size_t prev = 0, pos = 0, len = s.length();
+ do
+ {
+ pos = s.find(delimiter, prev);
+ if (pos == std::string::npos) pos = len;
+ if (pos>prev) result.push_back(s.substr(prev,pos-prev));
+ prev = pos + delimiter.length();
+ }
+ while (pos<len && prev<len);
+ return result;
+}
+
+/// split input string \a s by regular expression delimiter \a delimiter.
+/// returns a vector of non-empty strings that are between the delimiters
+StringVector split(const std::string &s,const std::regex &delimiter)
+{
+ StringVector result;
+ std::sregex_token_iterator iter(s.begin(), s.end(), delimiter, -1);
+ std::sregex_token_iterator end;
+ for ( ; iter != end; ++iter)
+ {
+ result.push_back(*iter);
+ }
+ return result;
+}
+
+/// find the index of a string in a vector of strings, returns -1 if the string could not be found
+int findIndex(StringVector &sv,const std::string &s)
+{
+ auto it = std::find(sv.begin(),sv.end(),s);
+ return it!=sv.end() ? (int)(it-sv.begin()) : -1;
+}
+
diff --git a/src/util.h b/src/util.h
index 410a3ea..f7f6171 100644
--- a/src/util.h
+++ b/src/util.h
@@ -26,6 +26,7 @@
#include <unordered_map>
#include <algorithm>
#include <functional>
+#include <regex>
#include <ctype.h>
#include "types.h"
@@ -458,6 +459,10 @@ bool openOutputFile(const char *outFile,QFile &f);
void writeExtraLatexPackages(FTextStream &t);
void writeLatexSpecialFormulaChars(FTextStream &t);
+StringVector split(const std::string &s,const std::string &delimiter);
+StringVector split(const std::string &s,const std::regex &delimiter);
+int findIndex(StringVector &sv,const std::string &s);
+
bool recognizeFixedForm(const char* contents, FortranFormat format);
FortranFormat convertFileNameFortranParserCode(QCString fn);
diff --git a/src/vhdlcode.l b/src/vhdlcode.l
index 59872f3..37cc720 100644
--- a/src/vhdlcode.l
+++ b/src/vhdlcode.l
@@ -30,6 +30,7 @@
#include <unordered_set>
#include <string>
+#include <regex>
/*
* includes
@@ -37,7 +38,6 @@
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
-#include <qregexp.h>
#include <qdir.h>
#include <qcstringlist.h>
@@ -226,9 +226,8 @@ XILINX "INST"|"NET"|"PIN"|"BLKNM"|"BUFG"|"COLLAPSE"|"CPLD"|"COMPGRP"|"CONFI
<Map>[^()\n,--]* { /* write and link a port map lines */
QCString tt(yytext);
VhdlDocGen::deleteAllChars(tt,',');
- QRegExp r("=>");
- QCStringList ql=QCStringList::split(r,tt);
- if (ql.count()>=2)
+ auto ql = split(tt.str(),"=>");
+ if (ql.size()>=2)
{
unsigned int index=0;
QCString t1=ql[0];
@@ -355,17 +354,17 @@ XILINX "INST"|"NET"|"PIN"|"BLKNM"|"BUFG"|"COLLAPSE"|"CPLD"|"COMPGRP"|"CONFI
}
<ParseType>{ENDEFUNC} {
- QRegExp regg("[\\s]");
QCString tt(yytext);
codifyLines(yyscanner,yytext,yyextra->currClass.data());
tt=tt.lower();
VhdlDocGen::deleteAllChars(tt,';');
tt.stripWhiteSpace();
- QCStringList ql=QCStringList::split(regg,tt);
- int index=ql.findIndex(QCString("if"))+1;
- index+=ql.findIndex(QCString("case"))+1;
- index+=ql.findIndex(QCString("loop"))+1;
- index+=ql.findIndex(QCString("generate"))+1;
+ static std::regex regg("[[:space:]]+");
+ auto ql = split(tt.str(),regg);
+ int index=findIndex(ql,"if")+1;
+ index+=findIndex(ql,"case")+1;
+ index+=findIndex(ql,"loop")+1;
+ index+=findIndex(ql,"generate")+1;
if (index==0)
{
BEGIN(Bases);
@@ -955,18 +954,18 @@ static bool checkVhdlString(yyscan_t yyscanner,QCString &name)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (name.isEmpty()) return false;
- static QRegExp regg("[\\s\"]");
int len=name.length();
if (name.at(0)=='"' && name.at(len-1)=='"' && len > 2)
{
- QCStringList qrl=QCStringList::split(regg,name);
+ std::string inside = name.str().substr(1,len-2);
+ static std::regex regg("[[:space:]]+");
+ auto qrl=split(inside,regg);
if (VhdlDocGen::isNumber(qrl[0]))
{
yyextra->code->codify("\"");
startFontClass(yyscanner,"vhdllogic");
- QCString mid=name.mid(1,len-2); //" 1223 "
- yyextra->code->codify(mid.data());
+ yyextra->code->codify(inside.c_str());
endFontClass(yyscanner);
yyextra->code->codify("\"");
}
@@ -1329,7 +1328,13 @@ static void generateClassOrGlobalLink(yyscan_t yyscanner,CodeOutputInterface &ol
cd = getClass(className.data());
if (!cd && curr_class)
{
- if (QCString(curr_class).contains(QRegExp("::"+QCString(clName)+"$"))) cd = getClass(curr_class);
+ QCString cls = curr_class;
+ QCString suffix = "::";
+ suffix+=clName;
+ if (cls.right(suffix.length())==suffix)
+ {
+ cd = getClass(curr_class);
+ }
}
while (cd)