summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-06-10 12:25:11 -0600
committerBrian Paul <brianp@vmware.com>2009-06-17 11:30:04 -0600
commit7323704262761a0346d99d8eee442ff4a5290c5f (patch)
treedd3cc1af7787071fd11eaa2348f044134e9ffa07 /src
parentd1056535dcea534ea1b54eb7e3e089fe7367af86 (diff)
glsl: Fix symbol replacement handling in preprocessor.
(cherry picked from master, commit d9617deb008b75f4a605a30408aeb1948139c33e)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index b2530a6554a..5455ba68626 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -1018,8 +1018,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]);
@@ -1061,21 +1059,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;