return -1;
}
} else {
- if (sl_pp_macro_expand(context, input, &i, NULL, &state, 0)) {
+ if (sl_pp_macro_expand(context, input, &i, NULL, &state, sl_pp_macro_expand_unknown_to_0)) {
free(state.out);
return -1;
}
break;
case SL_PP_IDENTIFIER:
- if (sl_pp_macro_expand(context, input, &i, NULL, &state, 0)) {
+ if (sl_pp_macro_expand(context, input, &i, NULL, &state, sl_pp_macro_expand_normal)) {
free(state.out);
return -1;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "sl_pp_public.h"
#include "sl_pp_macro.h"
#include "sl_pp_process.h"
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;
}
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;
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;
}
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;
void
sl_pp_macro_reset(struct sl_pp_macro *macro);
+enum sl_pp_macro_expand_behaviour {
+ sl_pp_macro_expand_normal,
+ sl_pp_macro_expand_mute,
+ sl_pp_macro_expand_unknown_to_0
+};
+
int
sl_pp_macro_expand(struct sl_pp_context *context,
const struct sl_pp_token_info *input,
unsigned int *pi,
struct sl_pp_macro *local,
struct sl_pp_process_state *state,
- int mute);
+ enum sl_pp_macro_expand_behaviour behaviour);
#endif /* SL_PP_MACRO_H */
break;
case SL_PP_IDENTIFIER:
- if (sl_pp_macro_expand(context, input, &i, NULL, &state, !context->if_value)) {
+ if (sl_pp_macro_expand(context, input, &i, NULL, &state,
+ context->if_value ? sl_pp_macro_expand_normal : sl_pp_macro_expand_mute)) {
return -1;
}
break;