Skip to content

Commit a018fd6

Browse files
authored
Merge pull request doxygen#12014 from albert-github/feature/issue_12009
issue doxygen#12009 Doctest/Catch2, requirements links and layout
2 parents a86028e + cbc12f2 commit a018fd6

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

src/pre.l

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ static inline void outputSpaces(yyscan_t yyscanner,char *s);
325325
static inline void outputSpace(yyscan_t yyscanner,char c);
326326
static inline void extraSpacing(yyscan_t yyscanner);
327327
static QCString expandMacro(yyscan_t yyscanner,const QCString &name);
328+
static QCString expandStandardMacro(yyscan_t yyscanner,const QCString &name);
328329
static void readIncludeFile(yyscan_t yyscanner,const QCString &inc);
329330
static void incrLevel(yyscan_t yyscanner);
330331
static void decrLevel(yyscan_t yyscanner);
@@ -702,6 +703,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
702703
//printf("Found it! #args=%d\n",def->nargs);
703704
yyextra->roundCount=0;
704705
yyextra->defArgsStr=yytext;
706+
QCString resultExpr;
705707
if (def->nargs==-1) // no function macro
706708
{
707709
QCString result = def->isPredefined && !def->expandAsDefined ?
@@ -849,18 +851,23 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
849851
/* end lex rule handling */
850852
<CopyLine,LexCopyLine>{ID} {
851853
Define *def=nullptr;
854+
QCString result;
852855
if ((yyextra->includeStack.empty() || yyextra->curlyCount>0) &&
853856
yyextra->macroExpansion &&
854857
(def=isDefined(yyscanner,yytext)) &&
855858
def->nargs==-1 &&
856859
(!yyextra->expandOnlyPredef || def->isPredefined)
857860
)
858861
{
859-
QCString result=def->isPredefined && !def->expandAsDefined ?
862+
result=def->isPredefined && !def->expandAsDefined ?
860863
def->definition :
861864
expandMacro(yyscanner,yytext);
862865
outputString(yyscanner,result);
863866
}
867+
else if (!(result = expandStandardMacro(yyscanner,yytext)).isEmpty())
868+
{
869+
outputString(yyscanner,result);
870+
}
864871
else
865872
{
866873
outputArray(yyscanner,yytext,yyleng);
@@ -3074,9 +3081,15 @@ static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in
30743081
while ((p=getNextId(expr,i,&l))!=-1) // search for an macro name
30753082
{
30763083
bool replaced=FALSE;
3084+
QCString resultExpr;
30773085
macroName=expr.mid(p,l);
30783086
//printf(" p=%d macroName=%s\n",p,qPrint(macroName));
3079-
if (p<2 || !(expr.at(p-2)=='@' && expr.at(p-1)=='-')) // no-rescan marker?
3087+
if (!(resultExpr = expandStandardMacro(yyscanner,macroName)).isEmpty())
3088+
{
3089+
QCString restExpr=expr.right(expr.length()-8-p);
3090+
expr=expr.left(p)+resultExpr+restExpr;
3091+
}
3092+
else if (p<2 || !(expr.at(p-2)=='@' && expr.at(p-1)=='-')) // no-rescan marker?
30803093
{
30813094
if (state->expandedDict.find(macroName.str())==state->expandedDict.end()) // expand macro
30823095
{
@@ -3117,7 +3130,7 @@ static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in
31173130
if (replaced) // expand the macro and rescan the expression
31183131
{
31193132
//printf(" replacing '%s'->'%s'\n",qPrint(expr.mid(p,len)),qPrint(expMacro));
3120-
QCString resultExpr=expMacro;
3133+
resultExpr=expMacro;
31213134
QCString restExpr=expr.right(expr.length()-len-p);
31223135
addSeparatorsIfNeeded(yyscanner,expr,resultExpr,restExpr,p);
31233136
processConcatOperators(resultExpr);
@@ -3524,6 +3537,35 @@ static QCString expandMacro(yyscan_t yyscanner,const QCString &name)
35243537
return n;
35253538
}
35263539

3540+
static QCString expandStandardMacro(yyscan_t yyscanner,const QCString &name)
3541+
{
3542+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3543+
QCString resultExpr;
3544+
if (name == "__LINE__")
3545+
{
3546+
return QCString().setNum(yyextra->yyLineNr);
3547+
}
3548+
else if (name == "__FILE__")
3549+
{
3550+
resultExpr = "\"";
3551+
resultExpr += yyextra->fileName;
3552+
resultExpr += "\"";
3553+
}
3554+
else if (name == "__DATE__")
3555+
{
3556+
resultExpr = "\"";
3557+
resultExpr += __DATE__;
3558+
resultExpr += "\"";
3559+
}
3560+
else if (name == "__TIME__")
3561+
{
3562+
resultExpr = "\"";
3563+
resultExpr += __TIME__;
3564+
resultExpr += "\"";
3565+
}
3566+
return resultExpr;
3567+
}
3568+
35273569
static void addDefine(yyscan_t yyscanner)
35283570
{
35293571
YY_EXTRA_TYPE state = preYYget_extra(yyscanner);

0 commit comments

Comments
 (0)