diff options
Diffstat (limited to 'src/pre.l')
-rw-r--r-- | src/pre.l | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -2,7 +2,7 @@ * * * - * Copyright (C) 1997-2008 by Dimitri van Heesch. + * Copyright (C) 1997-2010 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby @@ -96,6 +96,7 @@ static bool g_quoteArg; static DefineDict *g_fileDefineDict = new DefineDict(10009); static DefineDict *g_expandedDict; static int g_findDefArgContext; +static bool g_expectGuard; static QCString g_lastGuardName; static QCString g_incName; static QCString g_guardExpr; @@ -1237,6 +1238,7 @@ static void readIncludeFile(const QCString &inc) //fprintf(stderr,"Switching to include file %s\n",incFileName.data()); //preYYin=fs->filePtr; //yy_switch_to_buffer(yy_create_buffer(preYYin, YY_BUF_SIZE)); + g_expectGuard=TRUE; g_inputBuf=&fs->fileBuf; g_inputBufPos=0; yy_switch_to_buffer(yy_create_buffer(0, YY_BUF_SIZE)); @@ -1487,7 +1489,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) outputChar(*yytext); BEGIN( CopyLine ); } -<CopyLine>{ID}/{BN}{0,80}"(" { +<CopyLine>{ID}/{BN}{0,80}"(" { + g_expectGuard = FALSE; Define *def=0; //def=g_fileDefineDict->find(yytext); //printf("Search for define %s found=%d g_includeStack.isEmpty()=%d " @@ -1762,7 +1765,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) g_guardExpr+=" 1L "; else g_guardExpr+=" 0L "; - g_lastGuardName.resize(0); + g_lastGuardName=yytext; } <DefinedExpr1,DefinedExpr2>\n { // should not happen, handle anyway g_yyLineNr++; @@ -1906,7 +1909,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) g_defText.resize(0); g_defLitText.resize(0); g_defVarArgs = FALSE; - if ( g_defName!=g_lastGuardName ) + //printf("Guard check: %s!=%s || %d\n", + // g_defName.data(),g_lastGuardName.data(),g_expectGuard); + if ( g_defName!=g_lastGuardName || !g_expectGuard) { // define may appear in the output QCString tmp=(QCString)"#define "+g_defName; outputArray(tmp.data(),tmp.length()); @@ -2320,6 +2325,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) g_yyLineNr++; } <*>. { + g_expectGuard = FALSE; outputChar(*yytext); } @@ -2583,6 +2589,7 @@ void preprocessFile(const char *fileName,BufStr &input,BufStr &output) g_inputFileDef = g_yyFileDef; BEGIN( Start ); + g_expectGuard = TRUE; g_lastGuardName.resize(0); g_guardExpr.resize(0); |