Skip to content

Commit 463d003

Browse files
committed
issue doxygen#11668 [BUG] Emphasis with asterisks (*) does not work when at the beginning of a line of an ALIASES argument
1 parent 795e6f2 commit 463d003

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/commentcnv.l

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static inline void copyToOutput(yyscan_t yyscanner,const char *s,int len);
153153
static void startCondSection(yyscan_t yyscanner,const QCString &sectId);
154154
static void endCondSection(yyscan_t yyscanner);
155155
static void handleCondSectionId(yyscan_t yyscanner,const char *expression);
156-
static void replaceAliases(yyscan_t yyscanner,std::string_view s,bool replaceComment=false);
156+
static void replaceAliases(yyscan_t yyscanner,std::string_view s,bool replaceCppComment=false,bool replaceCComment=false);
157157
static int yyread(yyscan_t yyscanner,char *buf,int max_size);
158158
static void replaceComment(yyscan_t yyscanner,int offset);
159159
static void clearCommentStack(yyscan_t yyscanner);
@@ -1343,7 +1343,9 @@ SLASHopt [/]*
13431343
if (*yytext=='\n') { copyToOutput(yyscanner,"\n");}
13441344
}
13451345
<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{CMD}[a-z_A-Z][a-z_A-Z0-9-]* { // expand alias without arguments
1346-
replaceAliases(yyscanner,yytext,YY_START==ReadLine && yyextra->readLineCtx==SComment);
1346+
bool inCppComment = YY_START==ReadLine && yyextra->readLineCtx==SComment;
1347+
bool inCComment = YY_START==CComment;
1348+
replaceAliases(yyscanner,yytext,inCppComment,inCComment);
13471349
}
13481350
<CComment,ReadLine,IncludeFile,Verbatim,VerbatimCode>{B}?{CMD}"ilinebr"{B}{CMD}"ialias{" { // expand alias with arguments
13491351
yyextra->lastBlockContext=YY_START;
@@ -1410,8 +1412,9 @@ SLASHopt [/]*
14101412
if (!yyextra->lastEscaped) yyextra->blockCount--;
14111413
if (yyextra->blockCount==0)
14121414
{
1413-
replaceAliases(yyscanner,yyextra->aliasString.view(),
1414-
yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment);
1415+
bool inCppComment = yyextra->lastBlockContext==ReadLine && yyextra->readLineCtx==SComment;
1416+
bool inCComment = yyextra->lastBlockContext==CComment;
1417+
replaceAliases(yyscanner,yyextra->aliasString.view(),inCppComment,inCComment);
14151418
BEGIN( yyextra->lastBlockContext );
14161419
}
14171420
yyextra->lastEscaped=FALSE;
@@ -1947,7 +1950,7 @@ static bool readIncludeFile(yyscan_t yyscanner,const QCString &inc,const QCStrin
19471950
/** copies string \a s with length \a len to the output, while
19481951
* replacing any alias commands found in the string.
19491952
*/
1950-
static void replaceAliases(yyscan_t yyscanner,std::string_view s,bool replaceComment)
1953+
static void replaceAliases(yyscan_t yyscanner,std::string_view s,bool replaceCppComment,bool replaceCComment)
19511954
{
19521955
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
19531956
if (s.empty()) return;
@@ -1994,11 +1997,22 @@ static void replaceAliases(yyscan_t yyscanner,std::string_view s,bool replaceCom
19941997
//printf("replaceAliases(%s)->'%s' replaceComment=%d\n",qPrint(s),qPrint(result),replaceComment);
19951998
if (result!=s)
19961999
{
1997-
if (replaceComment) // In case we are replacing a multiline /// comment by a C style comment
1998-
// and we have new lines in the alias argument, we need to place back a /// for each new line
1999-
// to prevent breaking the multiline comment into multiple C style comments
2000+
QCString spaces;
2001+
if (yyextra->blockHeadCol>1)
20002002
{
2001-
result = substituteStringView(result,"\n","\n///");
2003+
spaces.fill(' ',yyextra->blockHeadCol-1);
2004+
}
2005+
if (replaceCppComment) // In case we are replacing a multiline /// comment by a C style comment
2006+
// and we have new lines in the alias argument, we need to place back a /// for each new line
2007+
// to prevent breaking the multiline comment into multiple C style comments
2008+
{
2009+
QCString replacement = "\n"+spaces+"///";
2010+
result = substituteStringView(result,"\n",replacement.view());
2011+
}
2012+
else if (replaceCComment)
2013+
{
2014+
QCString replacement = "\n"+spaces+" * ";
2015+
result = substituteStringView(result,"\n",replacement.view());
20022016
}
20032017
expAlias.push_back(cmd);
20042018
// add a ialias command to allow expansion of cmd again

0 commit comments

Comments
 (0)