Skip to content

Commit e871926

Browse files
committed
Fix issue where ALIAS argument was split over multiple lines (part 2)
1 parent d7601a9 commit e871926

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/commentcnv.l

+16-5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct commentcnvYY_state
112112
QCString incPrefix;
113113

114114
QCString aliasString;
115+
int aliasLines = 0;
115116
int blockCount = 0;
116117
bool lastEscaped = FALSE;
117118
int lastBlockContext= 0;
@@ -778,7 +779,7 @@ SLASHopt [/]*
778779
BEGIN(Scan);
779780
}
780781
}
781-
<CComment,CNComment>\n { /* new line in comment */
782+
<CComment,CNComment>\n { /* new line in comment */
782783
copyToOutput(yyscanner,yytext,yyleng);
783784
/* in case of Fortran always end of comment */
784785
if (yyextra->lang==SrcLangExt::Fortran)
@@ -1075,7 +1076,7 @@ SLASHopt [/]*
10751076
<CondLine>\n |
10761077
<CondLine>. { // forgot section id?
10771078
handleCondSectionId(yyscanner," "); // fake section id causing the section to be hidden unconditionally
1078-
if (*yytext=='\n') { yyextra->lineNr++; copyToOutput(yyscanner,"\n",1);}
1079+
if (*yytext=='\n') { copyToOutput(yyscanner,"\n",1);}
10791080
}
10801081
<CComment,ReadLine,IncludeFile>[\\@][a-z_A-Z][a-z_A-Z0-9-]* { // expand alias without arguments
10811082
replaceAliases(yyscanner,yytext);
@@ -1084,9 +1085,12 @@ SLASHopt [/]*
10841085
yyextra->lastBlockContext=YY_START;
10851086
yyextra->blockCount=1;
10861087
yyextra->aliasString=yytext;
1088+
yyextra->aliasLines=0;
10871089
yyextra->lastEscaped=0;
10881090
BEGIN( ReadAliasArgs );
10891091
}
1092+
<ReadAliasArgs>^[ \t]*"*" { // skip leading *
1093+
}
10901094
<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]+ { // skip leading special comments (see bug 618079)
10911095
}
10921096
<ReadAliasArgs>{CCE} { // oops, end of comment in the middle of an alias?
@@ -1111,8 +1115,8 @@ SLASHopt [/]*
11111115
yyextra->aliasString+=yytext;
11121116
}
11131117
<ReadAliasArgs>\n {
1114-
yyextra->aliasString+=' ';
1115-
yyextra->lineNr++;
1118+
yyextra->aliasString+=" ";
1119+
yyextra->aliasLines++;
11161120
yyextra->lastEscaped=FALSE;
11171121
}
11181122
<ReadAliasArgs>"{" {
@@ -1507,13 +1511,19 @@ static void replaceAliases(yyscan_t yyscanner,std::string_view s)
15071511
return;
15081512
}
15091513
std::string result = resolveAliasCmd(s);
1510-
//printf("replaceAliases(%s)->'%s'\n",qPrint(s),qPrint(result));
1514+
//printf("replaceAliases(%s)->'%s' lines=%d\n",qPrint(s),qPrint(result),yyextra->aliasLines);
15111515
if (result!=s)
15121516
{
15131517
yyextra->expandedAliases.insert(cmd);
15141518
result += " \\ialias{";
15151519
result += cmd;
15161520
result += "}";
1521+
if (yyextra->aliasLines>0)
1522+
{
1523+
yyextra->lineNr+=yyextra->aliasLines;
1524+
//printf("yyextra->lineNr=%d\n",yyextra->lineNr);
1525+
result += std::string{"\\ifile \""}+yyextra->fileName.str()+"\" \\iline "+std::to_string(yyextra->lineNr)+" ";
1526+
}
15171527
for (int i=(int)result.length()-1;i>=0;i--) unput(result[i]);
15181528
}
15191529
else
@@ -1582,6 +1592,7 @@ void convertCppComments(const BufStr &inBuf,BufStr &outBuf,const QCString &fileN
15821592
yyextra->lang = getLanguageFromFileName(fileName);
15831593
yyextra->pythonDocString = FALSE;
15841594
yyextra->lineNr = 1;
1595+
yyextra->aliasLines = 0;
15851596
yyextra->expandedAliases.clear();
15861597
while (!yyextra->condStack.empty()) yyextra->condStack.pop();
15871598
clearCommentStack(yyscanner);

0 commit comments

Comments
 (0)