summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/code.l10
-rw-r--r--src/qcstring.h6
2 files changed, 16 insertions, 0 deletions
diff --git a/src/code.l b/src/code.l
index 2b48c47..3acf41a 100644
--- a/src/code.l
+++ b/src/code.l
@@ -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,12 +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 (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 (startsWithKeyword(yytext,"typedef")) REJECT;
addType(yyscanner);
generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
yyextra->name+=yytext;
@@ -2168,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 */