summaryrefslogtreecommitdiffstats
path: root/src/commentcnv.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/commentcnv.l')
-rw-r--r--src/commentcnv.l41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/commentcnv.l b/src/commentcnv.l
index 6da02db..e9fc74b 100644
--- a/src/commentcnv.l
+++ b/src/commentcnv.l
@@ -41,6 +41,12 @@
#define ADDCHAR(c) g_outBuf->addChar(c)
#define ADDARRAY(a,s) g_outBuf->addArray(a,s)
+enum GuardType
+{
+ Guard_Cond,
+ Guard_CondNot
+};
+
struct CondCtx
{
CondCtx(int line,QCString id,bool b)
@@ -77,6 +83,7 @@ static bool g_lastEscaped;
static int g_lastBlockContext;
static bool g_pythonDocString;
+static GuardType guardType; // kind of guard for conditional section
static SrcLangExt g_lang;
@@ -118,7 +125,7 @@ static void replaceCommentMarker(const char *s,int len)
ADDCHAR(' ');
}
// copy comment line to output
- ADDARRAY(p,len-(p-s));
+ ADDARRAY(p,len-(int)(p-s));
}
static inline int computeIndent(const char *s)
@@ -172,14 +179,29 @@ static inline void copyToOutput(const char *s,int len)
static void startCondSection(const char *sectId)
{
g_condStack.push(new CondCtx(g_lineNr,sectId,g_skip));
- if (Config_getList("ENABLED_SECTIONS").find(sectId)!=-1)
+ if (guardType == Guard_Cond)
{
- //printf("*** Section is enabled!\n");
+ if (Config_getList("ENABLED_SECTIONS").find(sectId)!=-1)
+ {
+ //printf("*** Section is enabled!\n");
+ }
+ else
+ {
+ //printf("*** Section is disabled!\n");
+ g_skip=TRUE;
+ }
}
- else
+ else if (guardType == Guard_CondNot)
{
- //printf("*** Section is disabled!\n");
- g_skip=TRUE;
+ if (Config_getList("ENABLED_SECTIONS").find(sectId)!=-1)
+ {
+ //printf("*** Section is disabled!\n");
+ g_skip=TRUE;
+ }
+ else
+ {
+ //printf("*** Section is enabled!\n");
+ }
}
}
@@ -660,6 +682,12 @@ void replaceComment(int offset);
}
<CComment,ReadLine>[\\@]"cond"[ \t]+ { // conditional section
g_condCtx = YY_START;
+ guardType = Guard_Cond;
+ BEGIN(CondLine);
+ }
+<CComment,ReadLine>[\\@]"condnot"[ \t]+ { // conditional section
+ g_condCtx = YY_START;
+ guardType = Guard_CondNot;
BEGIN(CondLine);
}
<CComment,ReadLine>[\\@]"endcond"/[^a-z_A-Z0-9] { // end of conditional section
@@ -700,6 +728,7 @@ void replaceComment(int offset);
<CondLine>[ \t]*
<CComment,ReadLine>[\\@]"cond"[ \t\r]*/\n |
<CondLine>. { // forgot section id?
+ guardType = Guard_Cond;
if (YY_START!=CondLine) g_condCtx=YY_START;
bool oldSkip=g_skip;
startCondSection(" "); // fake section id causing the section to be hidden unconditionally