summaryrefslogtreecommitdiffstats
path: root/src/glsl/pp/sl_pp_define.c
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2009-06-26 12:26:05 +0200
committerMichal Krol <[email protected]>2009-09-07 10:11:52 +0200
commita294715612d14d64e12026361ff7cc29321607d6 (patch)
tree34f6fdc5ad039a504b7f99eba340b3668225af32 /src/glsl/pp/sl_pp_define.c
parent153b179862411e9de14d26bbcff16bc81f1edc91 (diff)
glsl: Allow for preprocessor macro redefinition.
Diffstat (limited to 'src/glsl/pp/sl_pp_define.c')
-rw-r--r--src/glsl/pp/sl_pp_define.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/glsl/pp/sl_pp_define.c b/src/glsl/pp/sl_pp_define.c
index e8a23fedcd8..0509646430a 100644
--- a/src/glsl/pp/sl_pp_define.c
+++ b/src/glsl/pp/sl_pp_define.c
@@ -105,22 +105,42 @@ int
sl_pp_process_define(struct sl_pp_context *context,
const struct sl_pp_token_info *input,
unsigned int first,
- unsigned int last,
- struct sl_pp_macro *macro)
+ unsigned int last)
{
+ int macro_name = -1;
+ struct sl_pp_macro *macro;
unsigned int i;
unsigned int body_len;
unsigned int j;
if (first < last && input[first].token == SL_PP_IDENTIFIER) {
- macro->name = input[first].data.identifier;
+ macro_name = input[first].data.identifier;
first++;
}
-
- if (macro->name == -1) {
+ if (macro_name == -1) {
return -1;
}
+ for (macro = context->macro; macro; macro = macro->next) {
+ if (macro->name == macro_name) {
+ break;
+ }
+ }
+
+ if (!macro) {
+ macro = sl_pp_macro_new();
+ if (!macro) {
+ return -1;
+ }
+
+ *context->macro_tail = macro;
+ context->macro_tail = &macro->next;
+ } else {
+ sl_pp_macro_reset(macro);
+ }
+
+ macro->name = macro_name;
+
/*
* If there is no whitespace between macro name and left paren, a macro
* formal argument list follows. This is the only place where the presence