Skip to content

Commit 1cfdf7b

Browse files
author
Dimitri van Heesch
committed
Merge pull request doxygen#435 from albert-github/feature/bug_700381
Bug 700381 - error state 21 with fortran code (fixed format)
2 parents 89123a2 + fdee5e9 commit 1cfdf7b

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/fortranscanner.l

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static bool endScope(Entry *scope, bool isGlobalRoot=FALSE);
214214
//static bool isTypeName(QCString name);
215215
static void resolveModuleProcedures(QList<Entry> &moduleProcedures, Entry *current_root);
216216
static int getAmpersandAtTheStart(const char *buf, int length);
217-
static int getAmpOrExclAtTheEnd(const char *buf, int length);
217+
static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch);
218218
static void truncatePrepass(int index);
219219
static void pushBuffer(QCString &buffer);
220220
static void popBuffer();
@@ -328,7 +328,7 @@ SCOPENAME ({ID}{BS}"::"{BS})*
328328
DBG_CTX((stderr, "---%s", yytext));
329329

330330
int indexStart = getAmpersandAtTheStart(yytext, (int)yyleng);
331-
int indexEnd = getAmpOrExclAtTheEnd(yytext, (int)yyleng);
331+
int indexEnd = getAmpOrExclAtTheEnd(yytext, (int)yyleng, '\0');
332332
if (indexEnd>=0 && yytext[indexEnd]!='&') //we are only interested in amp
333333
indexEnd=-1;
334334

@@ -1276,13 +1276,15 @@ static int getAmpersandAtTheStart(const char *buf, int length)
12761276
}
12771277

12781278
/* Returns ampersand index, comment start index or -1 if neither exist.*/
1279-
static int getAmpOrExclAtTheEnd(const char *buf, int length)
1279+
static int getAmpOrExclAtTheEnd(const char *buf, int length, char ch)
12801280
{
12811281
// Avoid ampersands in string and comments
12821282
int parseState = Start;
12831283
char quoteSymbol = 0;
12841284
int ampIndex = -1;
12851285
int commentIndex = -1;
1286+
quoteSymbol = ch;
1287+
if (ch != '\0') parseState = String;
12861288

12871289
for(int i=0; i<length && parseState!=Comment; i++)
12881290
{
@@ -1413,6 +1415,8 @@ static const char* prepassFixedForm(const char* contents)
14131415
int column=0;
14141416
int prevLineLength=0;
14151417
int prevLineAmpOrExclIndex=-1;
1418+
char prevQuote = '\0';
1419+
char thisQuote = '\0';
14161420
bool emptyLabel=TRUE;
14171421
bool commented=FALSE;
14181422
bool inSingle=FALSE;
@@ -1432,11 +1436,12 @@ static const char* prepassFixedForm(const char* contents)
14321436
switch(c) {
14331437
case '\n':
14341438
prevLineLength=column;
1435-
prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength);
1439+
prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote);
14361440
column=0;
14371441
emptyLabel=TRUE;
14381442
commented=FALSE;
14391443
newContents[j]=c;
1444+
prevQuote = thisQuote;
14401445
break;
14411446
case ' ':
14421447
case '\t':
@@ -1467,12 +1472,22 @@ static const char* prepassFixedForm(const char* contents)
14671472
}
14681473
else if (c == '\'')
14691474
{
1470-
if (!inDouble) inSingle = !inSingle;
1475+
if (!inDouble)
1476+
{
1477+
inSingle = !inSingle;
1478+
if (inSingle) thisQuote = c;
1479+
else thisQuote = '\0';
1480+
}
14711481
break;
14721482
}
14731483
else if (c == '"')
14741484
{
1475-
if (!inSingle) inDouble = !inDouble;
1485+
if (!inSingle)
1486+
{
1487+
inDouble = !inDouble;
1488+
if (inDouble) thisQuote = c;
1489+
else thisQuote = '\0';
1490+
}
14761491
break;
14771492
}
14781493
}

0 commit comments

Comments
 (0)