Fix Shader compilation failures with nested #ifdefs

TRAC #12054

Don't exit from CPPelse prematurely.
Clear elsedepth when entering a new #if nesting level.

Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch

Author:    Andrew Lewycky

git-svn-id: https://angleproject.googlecode.com/svn/trunk@214 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/preprocessor/cpp.c b/src/compiler/preprocessor/cpp.c
index beb895a..2b84d40 100644
--- a/src/compiler/preprocessor/cpp.c
+++ b/src/compiler/preprocessor/cpp.c
@@ -281,10 +281,10 @@
         atom = yylvalpp->sc_ident;
         if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){
             depth++; cpp->ifdepth++; cpp->elsetracker++;
+            cpp->elsedepth[cpp->elsetracker] = 0;
 		}
 		else if (atom == endifAtom) {
-            if(--depth<=0){
-		        cpp->elsedepth[cpp->elsetracker]=0;
+            if(--depth<0){
 			    --cpp->elsetracker;
                 if (cpp->ifdepth) 
                     --cpp->ifdepth;
@@ -461,6 +461,7 @@
     int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
     int res = 0, err = 0;
 	cpp->elsetracker++;
+    cpp->elsedepth[cpp->elsetracker] = 0;
     if (!cpp->ifdepth++)
         ifloc = *cpp->tokenLoc;
 	if(cpp->ifdepth >MAX_IF_NESTING){
@@ -489,6 +490,7 @@
 		return 0;
 	}
 	cpp->elsetracker++;
+    cpp->elsedepth[cpp->elsetracker] = 0;
     if (token != CPP_IDENTIFIER) {
             defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
     } else {
@@ -748,7 +750,6 @@
                 token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
 		    token = CPPelse(0, yylvalpp);
         } else if (yylvalpp->sc_ident == endifAtom) {
-			 cpp->elsedepth[cpp->elsetracker]=0;
 		     --cpp->elsetracker;
              if (!cpp->ifdepth){
                  CPPErrorToInfoLog("#endif mismatch");