mojoshader_preprocessor.c
changeset 748 818ae6582f24
parent 746 6b368eeaa3fc
child 754 d405cfa22392
--- a/mojoshader_preprocessor.c	Thu Apr 09 04:02:28 2009 -0400
+++ b/mojoshader_preprocessor.c	Thu Apr 09 10:51:58 2009 -0400
@@ -997,9 +997,12 @@
             goto handle_pp_define_failed;
         } // if
 
-        idents = (char **) Malloc(ctx, sizeof (char *) * params);
-        if (idents == NULL)
-            goto handle_pp_define_failed;
+        if (params > 0)
+        {
+            idents = (char **) Malloc(ctx, sizeof (char *) * params);
+            if (idents == NULL)
+                goto handle_pp_define_failed;
+        } // if
 
         // roll all the way back, do it again.
         memcpy(state, &saved, sizeof (IncludeState));
@@ -1018,8 +1021,11 @@
             dst[state->tokenlen] = '\0';
             idents[i] = dst;
 
-            lexer(state);
-            assert( (state->tokenval == ((Token) ')')) || (state->tokenval == ((Token) ',')) );
+            if (i < (params-1))
+            {
+                lexer(state);
+                assert(state->tokenval == ((Token) ','));
+            } // if
         } // for
 
         if (i != params)
@@ -1028,6 +1034,7 @@
             goto handle_pp_define_failed;
         } // if
 
+        lexer(state);
         assert(state->tokenval == ((Token) ')'));
         lexer(state);
     } // else if
@@ -1082,6 +1089,7 @@
         goto handle_pp_define_failed;
 
     assert(done);
+
     if (!add_define(ctx, sym, definition, idents, params))
         goto handle_pp_define_failed;