Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed dcl_2d usage.
  • Loading branch information
icculus committed Dec 12, 2008
1 parent d65b102 commit d49db27
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions mojoshader_assembler.c
Expand Up @@ -1043,7 +1043,7 @@ static int parse_args_DEFB(Context *ctx)
} // 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" };
Expand All @@ -1053,6 +1053,19 @@ static int parse_dcl_usage(const char *token, uint32 *val, int *issampler)
"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)
Expand Down Expand Up @@ -1093,7 +1106,7 @@ static int parse_args_DCL(Context *ctx)
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)
Expand Down

0 comments on commit d49db27

Please sign in to comment.