Skip to content

Commit 59de6f9

Browse files
committed
issue #11033 Illegal command '\ifile' found as part of a title section
Handle the `\ifile` and `\iline` command for the `\par` command. We also needed to properly reset the state properly as otherwise ``` \par EXAMPLE: \copybrief MkStringR \par EXAMPLE: \copydetails MkStringR ``` would give a warning regarding the second `\par` command.
1 parent 14fc65f commit 59de6f9

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

src/docparser.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,22 @@ bool DocParser::defaultHandleToken(DocNodeVariant *parent,int tok, DocNodeList &
13981398
case CMD_IMAGE:
13991399
handleImage(parent,children);
14001400
break;
1401+
case CMD_ILINE:
1402+
{
1403+
int state = tokenizer.getState();
1404+
tokenizer.setStateILine();
1405+
(void)tokenizer.lex();
1406+
tokenizer.setState(state);
1407+
}
1408+
break;
1409+
case CMD_IFILE:
1410+
{
1411+
int state = tokenizer.getState();
1412+
tokenizer.setStateIFile();
1413+
(void)tokenizer.lex();
1414+
tokenizer.setState(state);
1415+
}
1416+
break;
14011417
default:
14021418
return FALSE;
14031419
}

src/doctokenizer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ class DocTokenizer
134134
static const char *retvalToString(int retval);
135135

136136
void setLineNr(int lineno);
137+
void setState(int state);
137138
int getLineNr(void);
139+
int getState(void);
138140

139141
// operations on the scanner
140142
void findSections(const QCString &input,const Definition *d,
@@ -167,6 +169,7 @@ class DocTokenizer
167169
void setStateParam();
168170
void setStateXRefItem();
169171
void setStateFile();
172+
void setStateIFile();
170173
void setStatePattern();
171174
void setStateLink();
172175
void setStateCite();

src/doctokenizer.l

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
386386
%x St_XRefItem
387387
%x St_XRefItem2
388388
%x St_File
389+
%x St_IFile
389390
%x St_Pattern
390391
%x St_Link
391392
%x St_Cite
@@ -1404,6 +1405,16 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
14041405
<St_ILine>. {
14051406
return 0;
14061407
}
1408+
<St_IFile>{BLANK}*{FILEMASK} {
1409+
yyextra->fileName = QCString(yytext).stripWhiteSpace();
1410+
return TK_WORD;
1411+
}
1412+
<St_IFile>{BLANK}*"\""[^\n\"]+"\"" {
1413+
QCString text(yytext);
1414+
text = text.stripWhiteSpace();
1415+
yyextra->fileName = text.mid(1,text.length()-2);
1416+
return TK_WORD;
1417+
}
14071418
<St_File>{FILEMASK} {
14081419
yyextra->token.name = yytext;
14091420
return TK_WORD;
@@ -2072,6 +2083,13 @@ void DocTokenizer::setStateFile()
20722083
BEGIN(St_File);
20732084
}
20742085
2086+
void DocTokenizer::setStateIFile()
2087+
{
2088+
yyscan_t yyscanner = p->yyscanner;
2089+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2090+
BEGIN(St_IFile);
2091+
}
2092+
20752093
void DocTokenizer::setStatePattern()
20762094
{
20772095
yyscan_t yyscanner = p->yyscanner;
@@ -2259,4 +2277,18 @@ int DocTokenizer::getLineNr(void)
22592277
return yyextra->yyLineNr;
22602278
}
22612279
2280+
void DocTokenizer::setState(int state)
2281+
{
2282+
yyscan_t yyscanner = p->yyscanner;
2283+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2284+
BEGIN(state);
2285+
}
2286+
2287+
int DocTokenizer::getState(void)
2288+
{
2289+
yyscan_t yyscanner = p->yyscanner;
2290+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2291+
return YYSTATE;
2292+
}
2293+
22622294
#include "doctokenizer.l.h"

0 commit comments

Comments
 (0)