Fixed dcl_2d usage.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 12 Dec 2008 01:43:38 -0500
changeset 504 d79ae3b98f47
parent 503 ec8e7739cf5d
child 505 fd397ceab529
Fixed dcl_2d usage.
mojoshader_assembler.c
--- a/mojoshader_assembler.c	Fri Dec 12 00:58:10 2008 -0500
+++ b/mojoshader_assembler.c	Fri Dec 12 01:43:38 2008 -0500
@@ -1043,7 +1043,7 @@
 } // parse_args_DEFB
 
 
-static int parse_dcl_usage(const char *token, uint32 *val, int *issampler)
+static int parse_dcl_usage(Context *ctx, uint32 *val, int *issampler)
 {
     int i;
     static const char *samplerusagestrs[] = { "2d", "cube", "volume" };
@@ -1053,6 +1053,19 @@
         "color", "fog", "depth", "sample"
     };
 
+    // !!! FIXME: we need to clean this out in the tokenizer.
+    char token[sizeof (ctx->token)];
+    strcpy(token, ctx->token);
+    if (strcmp(token, "2") == 0)  // "2d" is two tokens.
+    {
+        if (nexttoken(ctx, 0, 0, 1, 1) == FAIL)
+            return FAIL;
+        else if (strcasecmp(ctx->token, "d") != 0)
+            pushback(ctx);
+        else
+            strcpy(token, "2d");
+    } // if
+
     for (i = 0; i < STATICARRAYLEN(usagestrs); i++)
     {
         if (strcasecmp(usagestrs[i], token) == 0)
@@ -1093,7 +1106,7 @@
         return fail(ctx, "Expected register or usage");
     else if (nexttoken(ctx, 0, 0, 0, 0) == FAIL)
         return FAIL;
-    else if (parse_dcl_usage(ctx->token, &usage, &issampler) == FAIL)
+    else if (parse_dcl_usage(ctx, &usage, &issampler) == FAIL)
         return FAIL;
 
     if (nexttoken(ctx, 0, 0, 0, 0) == FAIL)