# HG changeset patch # User Ryan C. Gordon # Date 1229064218 18000 # Node ID d79ae3b98f47db45ec55605c67911c3b67829af9 # Parent ec8e7739cf5d8919cbf88df886f515ff085f21d2 Fixed dcl_2d usage. diff -r ec8e7739cf5d -r d79ae3b98f47 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)