diff options
author | Michal Krol <[email protected]> | 2009-06-26 12:48:14 +0200 |
---|---|---|
committer | Michal Krol <[email protected]> | 2009-09-07 10:11:54 +0200 |
commit | 3dc2b5f71c2a519409becb6c1f177b5981fbacf7 (patch) | |
tree | ee06da321dfb52c67bd258a755a595b2f5222189 /src/glsl/pp/sl_pp_define.c | |
parent | a294715612d14d64e12026361ff7cc29321607d6 (diff) |
glsl: Implement `undef' preprocessor directive.
Diffstat (limited to 'src/glsl/pp/sl_pp_define.c')
-rw-r--r-- | src/glsl/pp/sl_pp_define.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/glsl/pp/sl_pp_define.c b/src/glsl/pp/sl_pp_define.c index 0509646430a..9bc9fb53599 100644 --- a/src/glsl/pp/sl_pp_define.c +++ b/src/glsl/pp/sl_pp_define.c @@ -176,3 +176,38 @@ sl_pp_process_define(struct sl_pp_context *context, return 0; } + + +int +sl_pp_process_undef(struct sl_pp_context *context, + const struct sl_pp_token_info *input, + unsigned int first, + unsigned int last) +{ + int macro_name = -1; + struct sl_pp_macro **pmacro; + struct sl_pp_macro *macro; + + if (first < last && input[first].token == SL_PP_IDENTIFIER) { + macro_name = input[first].data.identifier; + } + if (macro_name == -1) { + return 0; + } + + for (pmacro = &context->macro; *pmacro; pmacro = &(**pmacro).next) { + if ((**pmacro).name == macro_name) { + break; + } + } + if (!*pmacro) { + return 0; + } + + macro = *pmacro; + *pmacro = macro->next; + macro->next = NULL; + sl_pp_macro_free(macro); + + return 0; +} |