Commit ae845dea authored by Dimitri van Heesch's avatar Dimitri van Heesch
Browse files

Bug 700908 - code after \@cond is removed

parent 9a72b1b6
Loading
Loading
Loading
Loading
+31 −4
Original line number Original line Diff line number Diff line
@@ -59,6 +59,16 @@
#define DBG_CTX(x) do { } while(0)
#define DBG_CTX(x) do { } while(0)


#define YY_NEVER_INTERACTIVE 1
#define YY_NEVER_INTERACTIVE 1

struct CondCtx
{
  CondCtx(int line,QCString id,bool b) 
    : lineNr(line),sectionId(id), skip(b) {}
  int lineNr;
  QCString sectionId;
  bool skip;
};

struct FileState
struct FileState
{
{
  FileState(int size) : fileBuf(size), 
  FileState(int size) : fileBuf(size), 
@@ -360,7 +370,7 @@ static bool g_isImported;
static QCString           g_blockName;
static QCString           g_blockName;
static int                g_condCtx;
static int                g_condCtx;
static bool               g_skip;
static bool               g_skip;
static QStack<bool>       g_condStack;
static QStack<CondCtx>    g_condStack;
static bool               g_insideCS; // C# has simpler preprocessor
static bool               g_insideCS; // C# has simpler preprocessor
static bool               g_isSource;
static bool               g_isSource;


@@ -1613,7 +1623,7 @@ static void startCondSection(const char *sectId)
  //printf("startCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count());
  //printf("startCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count());
  CondParser prs;
  CondParser prs;
  bool expResult = prs.parse(g_yyFileName,g_yyLineNr,sectId);
  bool expResult = prs.parse(g_yyFileName,g_yyLineNr,sectId);
  g_condStack.push(new bool(g_skip));
  g_condStack.push(new CondCtx(g_yyLineNr,sectId,g_skip));
  if (!expResult)
  if (!expResult)
  {
  {
    g_skip=TRUE;
    g_skip=TRUE;
@@ -1629,8 +1639,8 @@ static void endCondSection()
  }
  }
  else
  else
  {
  {
    bool *ctx = g_condStack.pop();
    CondCtx *ctx = g_condStack.pop();
    g_skip=*ctx;
    g_skip=ctx->skip;
  }
  }
  //printf("endCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count());
  //printf("endCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count());
}
}
@@ -2457,6 +2467,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
					  }
					  }
					  BEGIN(SkipVerbatim);
					  BEGIN(SkipVerbatim);
  					}
  					}
<SkipCComment,SkipCPPComment>[\\@][\\@]"cond"[ \t]+ { // escaped @cond
  					  outputArray(yytext,(int)yyleng);
                                        }
<SkipCPPComment>[\\@]"cond"[ \t]+	{ // conditional section
<SkipCPPComment>[\\@]"cond"[ \t]+	{ // conditional section
                                          g_ccomment=TRUE;  
                                          g_ccomment=TRUE;  
                                          g_condCtx=YY_START;
                                          g_condCtx=YY_START;
@@ -2530,6 +2543,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
<SkipCond>[^\/\!*\\@\n]+                { }
<SkipCond>[^\/\!*\\@\n]+                { }
<SkipCond>"//"[/!]                      { g_ccomment=FALSE; }
<SkipCond>"//"[/!]                      { g_ccomment=FALSE; }
<SkipCond>"/*"[*!]                      { g_ccomment=TRUE; }
<SkipCond>"/*"[*!]                      { g_ccomment=TRUE; }
<SkipCond,SkipCComment,SkipCPPComment>[\\@][\\@]"endcond"/[^a-z_A-Z0-9] {
                                          if (!g_skip)
                                          {
  					    outputArray(yytext,(int)yyleng);
                                          }
                                        }
<SkipCond>[\\@]"endcond"/[^a-z_A-Z0-9]  { 
<SkipCond>[\\@]"endcond"/[^a-z_A-Z0-9]  { 
                                          bool oldSkip = g_skip;
                                          bool oldSkip = g_skip;
                                          endCondSection(); 
                                          endCondSection(); 
@@ -3088,6 +3107,14 @@ void preprocessFile(const char *fileName,BufStr &input,BufStr &output)
  preYYlex();
  preYYlex();
  g_lexInit=TRUE;
  g_lexInit=TRUE;


  while (!g_condStack.isEmpty())
  {
    CondCtx *ctx = g_condStack.pop();
    QCString sectionInfo = " ";
    if (ctx->sectionId!=" ") sectionInfo.sprintf(" with label %s ",ctx->sectionId.data()); 
    warn(fileName,ctx->lineNr,"Conditional section%sdoes not have "
	"a corresponding \\endcond command within this file.",sectionInfo.data());
  }
  // make sure we don't extend a \cond with missing \endcond over multiple files (see bug 624829)
  // make sure we don't extend a \cond with missing \endcond over multiple files (see bug 624829)
  forceEndCondSection();
  forceEndCondSection();