From: Brian Paul Date: Wed, 10 Jun 2009 14:39:58 +0000 (-0600) Subject: glsl: Fix symbol replacement handling in preprocessor. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=506989b20e18be0d2b849ad17710108832040207;p=mesa.git glsl: Fix symbol replacement handling in preprocessor. (cherry picked from master, commit d9617deb008b75f4a605a30408aeb1948139c33e) --- diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index 0e95cdb525e..f73400dbc64 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -1012,8 +1012,6 @@ preprocess_source (slang_string *output, const char *source, case TOKEN_DEFINE: { pp_symbol *symbol = NULL; - slang_string replacement; - expand_state es; /* Parse macro name. */ id = (const char *) (&prod[i]); @@ -1055,21 +1053,25 @@ preprocess_source (slang_string *output, const char *source, id = (const char *) (&prod[i]); idlen = _mesa_strlen (id); if (state.cond.top->effective) { + slang_string replacement; + expand_state es; + pp_annotate (output, ") %s", id); - } - slang_string_init(&replacement); - slang_string_pushs(&replacement, id, idlen); - i += idlen + 1; - /* Expand macro replacement. */ - es.output = &symbol->replacement; - es.input = slang_string_cstr(&replacement); - es.state = &state; - if (!expand(&es, &state.symbols)) { + slang_string_init(&replacement); + slang_string_pushs(&replacement, id, idlen); + + /* Expand macro replacement. */ + es.output = &symbol->replacement; + es.input = slang_string_cstr(&replacement); + es.state = &state; + if (!expand(&es, &state.symbols)) { + slang_string_free(&replacement); + goto error; + } slang_string_free(&replacement); - goto error; } - slang_string_free(&replacement); + i += idlen + 1; } break;