diff --git a/source/main.c b/source/main.c index 2002b1c..0aa9871 100644 --- a/source/main.c +++ b/source/main.c @@ -20,6 +20,8 @@ extern int tbsp_yy_init(void); extern int tbsp_yy_deinit(void); +extern int tbsp_c_yy_init(void); +extern int tbsp_c_yy_deinit(void); char * language = NULL; char * verbatim = NULL; @@ -107,6 +109,7 @@ signed main(const int argc, const char * const * const argv) { tbsp_yy_init(); tbsp_tab_init(); + tbsp_c_yy_init(); CHECKED_FOPEN(yyin, input_file_name, "r"); CHECKED_FOPEN(yyout, output_file_name, "w"); @@ -123,6 +126,7 @@ signed main(const int argc, const char * const * const argv) { } tbsp_yy_deinit(); + tbsp_c_yy_deinit(); free(output_file_name); free(input_file_name); free(verbatim); diff --git a/source/tbsp.l b/source/tbsp.l index 0a4043f..c34db3a 100644 --- a/source/tbsp.l +++ b/source/tbsp.l @@ -94,6 +94,7 @@ int tbsp_yy_init(void) { } int tbsp_yy_deinit(void) { + yy_delete_buffer(YY_CURRENT_BUFFER); sdsfree(buffer); return 0; } diff --git a/source/tbsp_c.l b/source/tbsp_c.l index e0a1a9d..ac8680c 100644 --- a/source/tbsp_c.l +++ b/source/tbsp_c.l @@ -114,10 +114,6 @@ identifier [a-zA-z][a-zA-z0-9_]* %% char * tbsp_c_expland_code(const char * const s) { - kv_init(query); - buffer = sdsnew(""); - query_string_buffer = sdsnew(""); - YY_BUFFER_STATE const b = yy_scan_string(s); tbsp_c_lex(); tbsp_c__delete_buffer(b); @@ -137,3 +133,17 @@ char * expand_c_query(void) { return r; } + +int tbsp_c_yy_init(void) { + kv_init(query); + buffer = sdsnew(""); + query_string_buffer = sdsnew(""); + return 0; +} + +int tbsp_c_yy_deinit(void) { + tbsp_c__delete_buffer(YY_CURRENT_BUFFER); + sdsfree(buffer); + sdsfree(query_string_buffer); + return 0; +}