Fixed #else preprocessor directive so it'll work with #elif.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 15 Feb 2009 01:53:08 -0500
changeset 625 bfb4016d9404
parent 624 99d1cf8a18a3
child 626 95d97e613112
Fixed #else preprocessor directive so it'll work with #elif.
mojoshader_internal.h
mojoshader_preprocessor.c
--- a/mojoshader_internal.h	Sat Feb 14 23:00:34 2009 -0500
+++ b/mojoshader_internal.h	Sun Feb 15 01:53:08 2009 -0500
@@ -380,6 +380,7 @@
     Token type;
     int linenum;
     int skipping;
+    int chosen;
     struct Conditional *next;
 } Conditional;
 
--- a/mojoshader_preprocessor.c	Sat Feb 14 23:00:34 2009 -0500
+++ b/mojoshader_preprocessor.c	Sun Feb 15 01:53:08 2009 -0500
@@ -789,6 +789,7 @@
     conditional->type = type;
     conditional->linenum = state->line - 1;
     conditional->skipping = skipping;
+    conditional->chosen = !skipping;
     conditional->next = prev;
     state->conditional_stack = conditional;
     return conditional;
@@ -820,9 +821,10 @@
         fail(ctx, "#else after #else");
     else
     {
-        // !!! FIXME: doesn't work for #elif
         cond->type = TOKEN_PP_ELSE;
-        cond->skipping = !cond->skipping;
+        cond->skipping = cond->chosen;
+        if (!cond->chosen)
+            cond->chosen = 1;
     } // else
 } // handle_pp_else