Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Preprocessor: fixed logic bug introduced when migrating to Buffer.
Fixes failing unit tests.
  • Loading branch information
icculus committed Nov 15, 2010
1 parent 1bad095 commit 1451e18
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mojoshader_preprocessor.c
Expand Up @@ -1431,7 +1431,9 @@ static int handle_macro_args(Context *ctx, const char *sym, const Define *def)

if (saw_params < expected)
{
const int origdeflen = (int) buffer_size(origbuffer);
char *origdefinition = buffer_flatten(origbuffer);
const int deflen = (int) buffer_size(buffer);
char *definition = buffer_flatten(buffer);
Define *p = get_define(ctx);
if ((!origdefinition) || (!definition) || (!p))
Expand All @@ -1446,15 +1448,15 @@ static int handle_macro_args(Context *ctx, const char *sym, const Define *def)

// trim any whitespace from the end of the string...
int i;
for (i = (int) buffer_size(buffer) - 1; i >= 0; i--)
for (i = deflen - 1; i >= 0; i--)
{
if (definition[i] == ' ')
definition[i] = '\0';
else
break;
} // for

for (i = (int) buffer_size(origbuffer) - 1; i >= 0; i--)
for (i = origdeflen - 1; i >= 0; i--)
{
if (origdefinition[i] == ' ')
origdefinition[i] = '\0';
Expand Down

0 comments on commit 1451e18

Please sign in to comment.