When processing identifiers in macro "calls", check both args and #defines.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 03 Mar 2010 08:06:44 -0800
changeset 881 a22fe996c5a4
parent 880 a3a9488856f7
child 882 dd526bab5a51
When processing identifiers in macro "calls", check both args and #defines.
mojoshader_preprocessor.c
--- a/mojoshader_preprocessor.c	Tue Mar 02 23:12:16 2010 -0800
+++ b/mojoshader_preprocessor.c	Wed Mar 03 08:06:44 2010 -0800
@@ -1387,11 +1387,16 @@
                             break;
                     } // else if
 
-                    // is this an arg in the current macro?
-                    //  This is a special case, we need to replace here.
-                    else if ((state->is_macro) && (t == TOKEN_IDENTIFIER))
+                    // see if a replacement is in order...
+                    // !!! FIXME: this fails if we get another macro with args:
+                    // !!! FIXME:  macro1(macro2(arg))
+                    else if (t == TOKEN_IDENTIFIER)
                     {
-                        const Define *arg = find_macro_arg(state);
+                        const Define *arg = NULL;
+                        if (state->is_macro)
+                            arg = find_macro_arg(state);
+                        if (arg == NULL)
+                            arg = find_define_by_token(ctx);
                         if (arg)
                         {
                             expr = arg->definition;