diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-29 17:12:22 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-29 17:12:22 (GMT) |
commit | 5b2a3efd94a5d009fd567933a9ac047c6c372b0e (patch) | |
tree | 8ddd92c3b0ea9b303ba00933696667621667f07a /src | |
parent | 5251cc5434a9b1cdd656609dfd8d7bf5f72a0a7c (diff) | |
download | Doxygen-5b2a3efd94a5d009fd567933a9ac047c6c372b0e.zip Doxygen-5b2a3efd94a5d009fd567933a9ac047c6c372b0e.tar.gz Doxygen-5b2a3efd94a5d009fd567933a9ac047c6c372b0e.tar.bz2 |
Minor adaptations to avoid matching 'typedefinition' as a typedef
Diffstat (limited to 'src')
-rw-r--r-- | src/code.l | 12 | ||||
-rw-r--r-- | src/qcstring.h | 6 |
2 files changed, 16 insertions, 2 deletions
@@ -249,6 +249,7 @@ static QCString escapeComment(yyscan_t yyscanner,const char *s); static bool skipLanguageSpecificKeyword(yyscan_t yyscanner,const char *kw); static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size); static void addVariable(yyscan_t yyscanner,QCString type,QCString name); +static bool startsWithKeyword(const QCString &str,const QCString &kw); //------------------------------------------------------------------- @@ -1135,14 +1136,14 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale yyextra->name+=yytext; } <Body>{SCOPENAME}/{BN}*[:;,)\]] { // "int var;" or "var, var2" or "debug(f) macro" , or int var : 5; - if (QCString(yytext).startsWith("typedef")) REJECT; + if (startsWithKeyword(yytext,"typedef")) REJECT; addType(yyscanner); // changed this to generateFunctionLink, see bug 624514 generateFunctionLink(yyscanner,*yyextra->code,yytext); yyextra->name+=yytext; } <Body>{SCOPENAME}/{B}* { // p->func() - if (QCString(yytext).startsWith("typedef")) REJECT; + if (startsWithKeyword(yytext,"typedef")) REJECT; addType(yyscanner); generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext); yyextra->name+=yytext; @@ -2170,6 +2171,13 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale /*@ ---------------------------------------------------------------------------- */ +static bool startsWithKeyword(const QCString &str,const QCString &kw) +{ + if (str.length()<kw.length()) return false; // string too short to match + return str==kw || // exact match + (str.startsWith(kw) && !isId(str.at(kw.length()))); // match that is not a substring +} + static void addVariable(yyscan_t yyscanner,QCString type,QCString name) { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; diff --git a/src/qcstring.h b/src/qcstring.h index 886573a..ba5ac95 100644 --- a/src/qcstring.h +++ b/src/qcstring.h @@ -392,6 +392,12 @@ class QCString return m_rep.rfind(s,0)==0; // looking "backward" starting and ending at index 0 } + bool startsWith( const QCString &s ) const + { + if (m_rep.empty() || s.isEmpty()) return s.isEmpty(); + return m_rep.rfind(s.str(),0)==0; // looking "backward" starting and ending at index 0 + } + #define HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING 0 #if HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING /** Converts the string to a plain C string */ |