summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-08-30 12:01:06 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-08-30 12:01:06 (GMT)
commit075771fd46ee7e6e4c7572b84cff194e887eddf4 (patch)
treeb0aab4e73649850c2eb0e22938132cf014d6a551
parenta53e985ab30ce7f8515d6e39c371879c9f6167c9 (diff)
downloadDoxygen-075771fd46ee7e6e4c7572b84cff194e887eddf4.zip
Doxygen-075771fd46ee7e6e4c7572b84cff194e887eddf4.tar.gz
Doxygen-075771fd46ee7e6e4c7572b84cff194e887eddf4.tar.bz2
issue #7927: PREDEFINED fails to replace argument
-rw-r--r--src/pre.l43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/pre.l b/src/pre.l
index d4ac400..04622bc 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -2036,7 +2036,7 @@ static bool replaceFunctionMacro(yyscan_t yyscanner,const QCString &expr,QCStrin
QCString arg;
int argCount=0;
bool done=FALSE;
-
+
// PHASE 1: read the macro arguments
if (def->nargs==0)
{
@@ -2395,7 +2395,7 @@ static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in
}
else if (def && def->nargs>=0) // function macro
{
- //printf(" >>>> call replaceFunctionMacro\n");
+ //printf(" >>>> call replaceFunctionMacro expr='%s'\n",qPrint(expr));
replaced=replaceFunctionMacro(yyscanner,expr,rest,p+l,len,def,expMacro,level);
//printf(" <<<< call replaceFunctionMacro: replaced=%d\n",replaced);
len+=l;
@@ -3186,22 +3186,34 @@ static void initPredefined(yyscan_t yyscanner,const char *fileName)
i_obrace<i_cbrace
) // predefined function macro definition
{
- //printf("predefined function macro '%s'\n",defStr);
- QRegExp reId("[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]*"); // regexp matching an id
+ bool varArgs = false;
+ int count = 0;
+ int i,pi,l;
std::map<std::string,int> argMap;
- int i=i_obrace+1,pi,l,count=0;
- // gather the formal arguments in a dictionary
- while (i<i_cbrace && (pi=reId.match(ds,i,&l)))
+ QRegExp reId("[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]*"); // regexp matching an id
+ if (ds.mid(i_obrace+1,i_cbrace-i_obrace-1)=="...")
{
- if (l>0) // see bug375037
- {
- argMap.emplace(toStdString(ds.mid(pi,l)),count);
- count++;
- i=pi+l;
- }
- else
+ varArgs = true;
+ argMap.emplace("__VA_ARGS__",count);
+ count++;
+ }
+ else
+ {
+ //printf("predefined function macro '%s'\n",qPrint(ds.mid(i_obrace+1,i_cbrace-i_obrace-1)));
+ i=i_obrace+1;
+ // gather the formal arguments in a dictionary
+ while (i<i_cbrace && (pi=reId.match(ds,i,&l)))
{
- i++;
+ if (l>0) // see bug375037
+ {
+ argMap.emplace(toStdString(ds.mid(pi,l)),count);
+ count++;
+ i=pi+l;
+ }
+ else
+ {
+ i++;
+ }
}
}
// strip definition part
@@ -3241,6 +3253,7 @@ static void initPredefined(yyscan_t yyscanner,const char *fileName)
def.nonRecursive = nonRecursive;
def.fileDef = state->yyFileDef;
def.fileName = fileName;
+ def.varArgs = varArgs;
state->contextDefines.insert(std::make_pair(def.name.str(),def));
//printf("#define '%s' '%s' #nargs=%d\n",