summaryrefslogtreecommitdiffstats
path: root/src/fortranscanner.l
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2016-01-02 14:07:21 (GMT)
committeralbert-github <albert.tests@gmail.com>2016-01-02 14:07:21 (GMT)
commitfdee5e9fade0ff5a578817048c6205f2a9acbced (patch)
treeeb173573b3a0016bfcc8ca1591ae63184b16abe9 /src/fortranscanner.l
parent295a467a2ebee260d95c7bb3e3c616554b7782b1 (diff)
downloadDoxygen-fdee5e9fade0ff5a578817048c6205f2a9acbced.zip
Doxygen-fdee5e9fade0ff5a578817048c6205f2a9acbced.tar.gz
Doxygen-fdee5e9fade0ff5a578817048c6205f2a9acbced.tar.bz2
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.
Diffstat (limited to 'src/fortranscanner.l')
-rw-r--r--src/fortranscanner.l27
1 files 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<Entry> &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<length && parseState!=Comment; i++)
{
@@ -1410,6 +1412,8 @@ static const char* prepassFixedForm(const char* contents)
int column=0;
int prevLineLength=0;
int prevLineAmpOrExclIndex=-1;
+ char prevQuote = '\0';
+ char thisQuote = '\0';
bool emptyLabel=TRUE;
bool commented=FALSE;
bool inSingle=FALSE;
@@ -1429,11 +1433,12 @@ static const char* prepassFixedForm(const char* contents)
switch(c) {
case '\n':
prevLineLength=column;
- prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength);
+ prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote);
column=0;
emptyLabel=TRUE;
commented=FALSE;
newContents[j]=c;
+ prevQuote = thisQuote;
break;
case ' ':
case '\t':
@@ -1464,12 +1469,22 @@ static const char* prepassFixedForm(const char* contents)
}
else if (c == '\'')
{
- if (!inDouble) inSingle = !inSingle;
+ if (!inDouble)
+ {
+ inSingle = !inSingle;
+ if (inSingle) thisQuote = c;
+ else thisQuote = '\0';
+ }
break;
}
else if (c == '"')
{
- if (!inSingle) inDouble = !inDouble;
+ if (!inSingle)
+ {
+ inDouble = !inDouble;
+ if (inDouble) thisQuote = c;
+ else thisQuote = '\0';
+ }
break;
}
}