From fdee5e9fade0ff5a578817048c6205f2a9acbced Mon Sep 17 00:00:00 2001 From: albert-github Date: Sat, 2 Jan 2016 15:07:21 +0100 Subject: Bug 700381 - error state 21 with fortran code (fixed format) Problem is caused by similar quotes inside quotes, in Fortran it is possible to "escape" quotes by doubling them. --- src/fortranscanner.l | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/fortranscanner.l b/src/fortranscanner.l index bd1fe83..84749c1 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -214,7 +214,7 @@ static bool endScope(Entry *scope, bool isGlobalRoot=FALSE); //static bool isTypeName(QCString name); static void resolveModuleProcedures(QList &moduleProcedures, Entry *current_root); static int getAmpersandAtTheStart(const char *buf, int length); -static int getAmpOrExclAtTheEnd(const char *buf, int length); +static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch); static void truncatePrepass(int index); static void pushBuffer(QCString &buffer); static void popBuffer(); @@ -328,7 +328,7 @@ SCOPENAME ({ID}{BS}"::"{BS})* DBG_CTX((stderr, "---%s", yytext)); int indexStart = getAmpersandAtTheStart(yytext, (int)yyleng); - int indexEnd = getAmpOrExclAtTheEnd(yytext, (int)yyleng); + int indexEnd = getAmpOrExclAtTheEnd(yytext, (int)yyleng, '\0'); if (indexEnd>=0 && yytext[indexEnd]!='&') //we are only interested in amp indexEnd=-1; @@ -1273,13 +1273,15 @@ static int getAmpersandAtTheStart(const char *buf, int length) } /* Returns ampersand index, comment start index or -1 if neither exist.*/ -static int getAmpOrExclAtTheEnd(const char *buf, int length) +static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch) { // Avoid ampersands in string and comments int parseState = Start; char quoteSymbol = 0; int ampIndex = -1; int commentIndex = -1; + quoteSymbol = ch; + if (ch != '\0') parseState = String; for(int i=0; i