diff options
Diffstat (limited to 'src/pre.l')
-rw-r--r-- | src/pre.l | 52 |
1 files changed, 35 insertions, 17 deletions
@@ -1826,7 +1826,7 @@ static FileState *findFile(yyscan_t yyscanner, const char *fileName,bool localIn { YY_EXTRA_TYPE state = preYYget_extra(yyscanner); //printf("** findFile(%s,%d) state->yyFileName=%s\n",fileName,localInclude,state->yyFileName.data()); - if (portable_isAbsolutePath(fileName)) + if (Portable::isAbsolutePath(fileName)) { FileState *fs = checkAndOpenFile(yyscanner,fileName,alreadyIncluded); if (fs) @@ -1934,7 +1934,7 @@ static QCString extractTrailingComment(const char *s) static int getNextChar(yyscan_t yyscanner,const QCString &expr,QCString *rest,uint &pos); static int getCurrentChar(yyscan_t yyscanner,const QCString &expr,QCString *rest,uint pos); static void unputChar(yyscan_t yyscanner,const QCString &expr,QCString *rest,uint &pos,char c); -static void expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,int pos,int level); +static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,int pos,int level); static QCString stringize(const QCString &s) { @@ -2084,7 +2084,7 @@ static bool replaceFunctionMacro(yyscan_t yyscanner,const QCString &expr,QCStrin } if (cc!='(') { - unputChar(yyscanner,expr,rest,j,' '); + unputChar(yyscanner,expr,rest,j,cc); return FALSE; } getNextChar(yyscanner,expr,rest,j); // eat the '(' character @@ -2385,20 +2385,19 @@ static int getNextId(const QCString &expr,int p,int *l) * starting at position \a pos. * May read additional characters from the input while re-scanning! */ -static void expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,int pos,int level) +static bool expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,int pos,int level) { YY_EXTRA_TYPE state = preYYget_extra(yyscanner); - //printf(">expandExpression(expr='%s',rest='%s',pos=%d,level=%d)\n",expr.data(),rest ? rest->data() : 0, pos, level); + //printf(">expandExpression(expr='%s',rest='%s',pos=%d,level=%d)\n",expr.data(),rest ? rest->data() : "", pos, level); if (expr.isEmpty()) { //printf("<expandExpression: empty\n"); - return; + return TRUE; } if (state->expansionDict.find(expr)!=0) // check for recursive expansions { - expr=expr.left(pos)+"@-"+expr.right(expr.length()-pos); //printf("<expandExpression: already expanded expr='%s'\n",expr.data()); - return; + return FALSE; } else { @@ -2462,16 +2461,25 @@ static void expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in QCString resultExpr=expMacro; QCString restExpr=expr.right(expr.length()-len-p); processConcatOperators(resultExpr); - //printf(" macroName=%s def->nonRecursive=%d\n",macroName.data(),def->nonRecursive); + //printf(" macroName=%s restExpr='%s' def->nonRecursive=%d\n",macroName.data(),restExpr.data(),def->nonRecursive); + bool expanded=false; if (def && !def->nonRecursive) { state->expandedDict->insert(macroName,def); - expandExpression(yyscanner,resultExpr,&restExpr,0,level+1); + expanded = expandExpression(yyscanner,resultExpr,&restExpr,0,level+1); state->expandedDict->remove(macroName); } - expr=expr.left(p)+resultExpr+restExpr; - //printf(" new expression: '%s' old i=%d new i=%d\n",expr.data(),i,p); - i=p; + if (expanded) + { + expr=expr.left(p)+resultExpr+restExpr; + //printf(" new expression: '%s' old i=%d new i=%d\n",expr.data(),i,p); + i=p; + } + else + { + expr=expr.left(p)+"@-"+expr.right(expr.length()-p); + i=p+l+2; + } } else // move to the next macro name { @@ -2494,6 +2502,7 @@ static void expandExpression(yyscan_t yyscanner,QCString &expr,QCString *rest,in } } //printf("<expandExpression(expr='%s',rest='%s',pos=%d,level=%d)\n",expr.data(),rest ? rest->data() : 0, pos,level); + return TRUE; } /*! @brief Process string or character literal. @@ -2786,7 +2795,7 @@ static void addDefine(yyscan_t yyscanner) { ArgumentList argList; //printf("addDefine() state->defName='%s' state->defArgsStr='%s'\n",state->defName.data(),state->defArgsStr.data()); - stringToArgumentList(state->defArgsStr,argList); + stringToArgumentList(SrcLangExt_Cpp, state->defArgsStr,argList); md->setArgumentList(argList); } //printf("Setting initializer for '%s' to '%s'\n",state->defName.data(),state->defText.data()); @@ -2805,7 +2814,15 @@ static void addDefine(yyscan_t yyscanner) while ((c=*p++) && (c==' ' || c=='\t')) k++; state->defLitText=state->defLitText.mid(l+1,k-l-1)+state->defLitText.stripWhiteSpace(); } - md->setInitializer(state->defLitText.stripWhiteSpace()); + QCString defLitTextStripped = state->defLitText.stripWhiteSpace(); + if (defLitTextStripped.contains('\n')>=1) + { + md->setInitializer(state->defLitText); + } + else + { + md->setInitializer(defLitTextStripped); + } //printf("pre.l: md->setFileDef(%p)\n",state->inputFileDef); md->setFileDef(state->inputFileDef); @@ -3315,10 +3332,11 @@ void Preprocessor::processFile(const char *fileName,BufStr &input,BufStr &output def->fileDef = state->yyFileDef; def->fileName = fileName; state->defineManager.addDefine(state->yyFileName,def); + + //printf("#define '%s' '%s' #nargs=%d\n", + // def->name.data(),def->definition.data(),def->nargs); } - //printf("#define '%s' '%s' #nargs=%d\n", - // def->name.data(),def->definition.data(),def->nargs); } else if ((i_obrace==-1 || i_obrace>i_equals) && (i_cbrace==-1 || i_cbrace>i_equals) && |