Index: doc/commands.doc
===================================================================
RCS file: /cygdrive/d/cvs_doxygen/doxygen/doxygen/doc/commands.doc,v
retrieving revision 1.2
diff -u -r1.2 commands.doc
--- doc/commands.doc	29 Jul 2012 11:29:20 -0000	1.2
+++ doc/commands.doc	2 Sep 2012 11:16:57 -0000
@@ -55,6 +55,7 @@
 \refitem cmdclass \\class
 \refitem cmdcode \\code
 \refitem cmdcond \\cond
+\refitem cmdcondnot \\condnot
 \refitem cmdcopybrief \\copybrief
 \refitem cmdcopydetails \\copydetails
 \refitem cmdcopydoc \\copydoc
@@ -1125,7 +1126,29 @@
 The output will be different depending on whether or not \c ENABLED_SECTIONS
 contains \c TEST, or \c DEV
 
-  \sa section \ref cmdendcond "\\endcond".
+  \sa section \ref cmdcondnot "\\condnot" and section \ref cmdendcond "\\endcond".
+
+<hr>
+\section cmdcondnot \\condnot <section-label>
+
+  \addindex \\condnot
+  Starts a conditional section that ends with a corresponding
+  \ref cmdendcond "\\endcond" command, which is typically found in
+  another comment block. The main purpose of this pair of
+  commands is to (conditionally) exclude part of a file from processing
+  (in older version of doxygen this could only be achieved using C preprocessor commands).
+
+  The section between \\condnot and \\endcond commands can be excluded by
+  adding its section label to the \ref cfg_enabled_sections "ENABLED_SECTIONS"
+  configuration option.
+
+  For conditional sections within a comment block one should
+  use a \ref cmdif "\\if" ... \ref cmdendif "\\endif" block.
+
+  Conditional sections can be nested. In this case a nested section will only
+  be shown if it and its containing section are included.
+
+  \sa section \ref cmdcond "\\cond" and section \ref cmdendcond "\\endcond".
 
 <hr>
 \section cmdcopyright \\copyright { copyright description }
@@ -1197,9 +1220,9 @@
 \section cmdendcond \\endcond
 
   \addindex \\endcond
-  Ends a conditional section that was started by \ref cmdcond "\\cond".
+  Ends a conditional section that was started by \ref cmdcond "\\cond" or \ref cmdcondnot "\\condnot".
 
-  \sa section \ref cmdcond "\\cond".
+  \sa section \ref cmdcond "\\cond" and section \ref cmdcondnot "\\condnot".
 
 <hr>
 \section cmdendif \\endif
Index: doc/faq.doc
===================================================================
RCS file: /cygdrive/d/cvs_doxygen/doxygen/doxygen/doc/faq.doc,v
retrieving revision 1.1
diff -u -r1.1 faq.doc
--- doc/faq.doc	22 May 2012 19:35:49 -0000	1.1
+++ doc/faq.doc	2 Sep 2012 10:23:06 -0000
@@ -80,7 +80,7 @@
 <li><b>How can I make doxygen ignore some code fragment?</b>
 
 The new and easiest way is to add one comment block 
-with a \ref cmdcond "\\cond" command at the start and one comment block 
+with a \ref cmdcond "\\cond" or \ref cmdcondnot "\\condnot" command at the start and one comment block 
 with a \ref cmdendcond "\\endcond" command at the end of the piece of
 code that should be ignored. This should be within the same file of course.
 
Index: src/commentcnv.l
===================================================================
RCS file: /cygdrive/d/cvs_doxygen/doxygen/doxygen/src/commentcnv.l,v
retrieving revision 1.5
diff -u -r1.5 commentcnv.l
--- src/commentcnv.l	12 Aug 2012 12:06:56 -0000	1.5
+++ src/commentcnv.l	2 Sep 2012 10:10:09 -0000
@@ -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 int      g_lastBlockContext;
 static bool     g_pythonDocString;
 
+static GuardType        guardType;           // kind of guard for conditional section
 
 static SrcLangExt g_lang;
 
@@ -172,14 +179,29 @@
 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 @@
   				   }
 <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 @@
 <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
Index: src/pre.l
===================================================================
RCS file: /cygdrive/d/cvs_doxygen/doxygen/doxygen/src/pre.l,v
retrieving revision 1.1
diff -u -r1.1 pre.l
--- src/pre.l	22 May 2012 19:36:50 -0000	1.1
+++ src/pre.l	2 Sep 2012 09:57:11 -0000
@@ -51,7 +51,11 @@
 #include "entry.h"
 
 #define YY_NEVER_INTERACTIVE 1
-  
+enum GuardType
+{
+  Guard_Cond,
+  Guard_CondNot
+}; 
 
 struct FileState
 {
@@ -356,6 +360,7 @@
 
 static bool               g_lexInit = FALSE;
 
+static GuardType        guardType;           // kind of guard for conditional section
 //DefineDict* getGlobalDefineDict() 
 //{
 //  return g_globalDefineDict;
@@ -1651,9 +1656,19 @@
 static void startCondSection(const char *sectId)
 {
   g_condStack.push(new bool(g_skip));
-  if (Config_getList("ENABLED_SECTIONS").find(sectId)==-1)
+  if (guardType == Guard_Cond)
+  {
+    if (Config_getList("ENABLED_SECTIONS").find(sectId)==-1)
+    {
+      g_skip=TRUE;
+    }
+  }
+  else if (guardType == Guard_CondNot)
   {
-    g_skip=TRUE;
+    if (Config_getList("ENABLED_SECTIONS").find(sectId)!=-1)
+    {
+      g_skip=TRUE;
+    }
   }
 }
 
@@ -2451,6 +2466,13 @@
 					  BEGIN(SkipVerbatim);
   					}
 <SkipCComment,SkipCPPComment>[\\@]"cond"[ \t]+	{ // conditional section
+                                          guardType = Guard_Cond;
+  					  g_condCtx = YY_START;
+  					  outputArray(yytext,yyleng);
+  					  BEGIN(CondLine);
+  					}
+<SkipCComment,SkipCPPComment>[\\@]"condnot"[ \t]+	{ // conditional section
+                                          guardType = Guard_CondNot;
   					  g_condCtx = YY_START;
   					  outputArray(yytext,yyleng);
   					  BEGIN(CondLine);
@@ -2461,6 +2483,7 @@
   					  BEGIN(g_condCtx);
   					}
 <SkipCComment,SkipCPPComment>[\\@]"cond"[ \t\r]*/\n {
+                                          guardType = Guard_Cond;
   					  g_condCtx = YY_START;
   					  outputArray(yytext,yyleng);
   					}
