@@ -46,6 +46,12 @@ sl_pp_context_create(void) | |||
return NULL; | |||
} | |||
context->getc_buf = malloc(64 * sizeof(char)); | |||
if (!context->getc_buf) { | |||
sl_pp_context_destroy(context); | |||
return NULL; | |||
} | |||
context->macro_tail = &context->macro; | |||
context->if_ptr = SL_PP_MAX_IF_NESTING; | |||
context->if_value = 1; | |||
@@ -62,6 +68,7 @@ sl_pp_context_destroy(struct sl_pp_context *context) | |||
if (context) { | |||
free(context->cstr_pool); | |||
sl_pp_macro_free(context->macro); | |||
free(context->getc_buf); | |||
free(context); | |||
} | |||
} |
@@ -30,6 +30,7 @@ | |||
#include "sl_pp_dict.h" | |||
#include "sl_pp_macro.h" | |||
#include "sl_pp_purify.h" | |||
#define SL_PP_MAX_IF_NESTING 64 | |||
@@ -53,10 +54,12 @@ struct sl_pp_context { | |||
unsigned int line; | |||
unsigned int file; | |||
}; | |||
int | |||
sl_pp_context_add_unique_str(struct sl_pp_context *context, | |||
const char *str); | |||
struct sl_pp_purify_state pure; | |||
char *getc_buf; | |||
unsigned int getc_buf_size; | |||
unsigned int getc_buf_capacity; | |||
}; | |||
#endif /* SL_PP_CONTEXT_H */ |
@@ -25,6 +25,7 @@ | |||
* | |||
**************************************************************************/ | |||
#include "sl_pp_public.h" | |||
#include "sl_pp_context.h" | |||
#include "sl_pp_dict.h" | |||
@@ -45,6 +45,10 @@ sl_pp_context_destroy(struct sl_pp_context *context); | |||
const char * | |||
sl_pp_context_error_message(const struct sl_pp_context *context); | |||
int | |||
sl_pp_context_add_unique_str(struct sl_pp_context *context, | |||
const char *str); | |||
const char * | |||
sl_pp_context_cstr(const struct sl_pp_context *context, | |||
int offset); |
@@ -123,6 +123,7 @@ struct sl_pp_token_info { | |||
int | |||
sl_pp_tokenise(struct sl_pp_context *context, | |||
const char *input, | |||
const struct sl_pp_purify_options *options, | |||
struct sl_pp_token_info **output); | |||
#endif /* SL_PP_TOKEN_H */ |