diff options
author | Michal Krol <[email protected]> | 2009-11-20 08:59:50 +0100 |
---|---|---|
committer | Michal Krol <[email protected]> | 2009-11-20 08:59:50 +0100 |
commit | b89cd8afc510541a18f2f5c04884637626e104e1 (patch) | |
tree | 884ab2925e280177e7ae834d7a546bc99959f225 /src/glsl/pp/sl_pp_macro.c | |
parent | 547ac2869b1e1bbdbf8e51cd40d50e6ab0f4f9f1 (diff) |
glsl/pp: Expand unknown identifiers to 0 in if/elif expressions.
Diffstat (limited to 'src/glsl/pp/sl_pp_macro.c')
-rw-r--r-- | src/glsl/pp/sl_pp_macro.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/glsl/pp/sl_pp_macro.c b/src/glsl/pp/sl_pp_macro.c index d6c32a0e782..29f1229dd7d 100644 --- a/src/glsl/pp/sl_pp_macro.c +++ b/src/glsl/pp/sl_pp_macro.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include "sl_pp_public.h" #include "sl_pp_macro.h" #include "sl_pp_process.h" @@ -122,8 +123,9 @@ sl_pp_macro_expand(struct sl_pp_context *context, unsigned int *pi, struct sl_pp_macro *local, struct sl_pp_process_state *state, - int mute) + enum sl_pp_macro_expand_behaviour behaviour) { + int mute = (behaviour == sl_pp_macro_expand_mute); int macro_name; struct sl_pp_macro *macro = NULL; struct sl_pp_macro *actual_arg = NULL; @@ -183,7 +185,12 @@ sl_pp_macro_expand(struct sl_pp_context *context, } if (!macro) { - if (!mute) { + if (behaviour == sl_pp_macro_expand_unknown_to_0) { + if (_out_number(context, state, 0)) { + strcpy(context->error_msg, "out of memory"); + return -1; + } + } else if (!mute) { if (sl_pp_process_out(state, &input[*pi])) { strcpy(context->error_msg, "out of memory"); return -1; @@ -274,7 +281,7 @@ sl_pp_macro_expand(struct sl_pp_context *context, break; case SL_PP_IDENTIFIER: - if (sl_pp_macro_expand(context, input, &i, local, &arg_state, 0)) { + if (sl_pp_macro_expand(context, input, &i, local, &arg_state, sl_pp_macro_expand_normal)) { free(arg_state.out); return -1; } @@ -339,7 +346,7 @@ sl_pp_macro_expand(struct sl_pp_context *context, break; case SL_PP_IDENTIFIER: - if (sl_pp_macro_expand(context, macro->body, &j, actual_arg, state, mute)) { + if (sl_pp_macro_expand(context, macro->body, &j, actual_arg, state, behaviour)) { return -1; } break; |