From 578f879e26ce4e3f1cd7693cb9d9a8a6f35cc389 Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Mon, 20 Dec 2021 19:47:56 +0100 Subject: make set + @log/@info/@error conditional --- src/sp_config_scanner.re | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/sp_config_scanner.re') diff --git a/src/sp_config_scanner.re b/src/sp_config_scanner.re index b0ee5d5..6b52b20 100644 --- a/src/sp_config_scanner.re +++ b/src/sp_config_scanner.re @@ -182,6 +182,7 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key "sp" { kw_i = 0; goto yyc_rule; } end { ret = SUCCESS; goto out; } "set" ws+ @t1 keyword @t2 ws+ @t3 string @t4 ws* ";"? { + if (!cond_res[0]) { goto yyc_init; } char *key = (char*)t1; int keylen = t2-t1; zend_string *tmp = zend_hash_str_find_ptr(&vars, key, keylen); @@ -192,19 +193,22 @@ zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_key zend_hash_str_add_ptr(&vars, key, keylen, tmp); goto yyc_init; } - "@condition" ws+ { goto yyc_cond; } - "@end_condition" ws* ";" { cond_res[0] = 1; goto yyc_init; } - ( "@log" | "@info" ) ws+ @t1 string @t2 { + "@condition" ws+ { cond_res_i = 0; goto yyc_cond; } + "@end_condition" ws* ";" { cond_res[0] = 1; cond_res_i = 0; goto yyc_init; } + ( "@log" | "@info" ) ws+ @t1 string @t2 ";"? { + if (!cond_res[0]) { goto yyc_init; } TMPSTR(tmpstr, t2, t1); cs_log_info("[line %d]: %s", lineno, tmpstr); goto yyc_init; } - ( "@warn" | "@warning" ) ws+ @t1 string @t2 { + ( "@warn" | "@warning" ) ws+ @t1 string @t2 ";"? { + if (!cond_res[0]) { goto yyc_init; } TMPSTR(tmpstr, t2, t1); cs_log_warning("[line %d]: %s", lineno, tmpstr); goto yyc_init; } - ( "@err" | "@error" ) ws+ @t1 string @t2 { + ( "@err" | "@error" ) ws+ @t1 string @t2 ";"? { + if (!cond_res[0]) { goto yyc_init; } TMPSTR(tmpstr, t2, t1); cs_log_error("[line %d]: %s", lineno, tmpstr); goto out; -- cgit v1.3