From eb2d085cce6f93a15c9893fe9b43e9d2b9cc8339 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Sat, 18 May 2024 17:30:29 +1100 Subject: [PATCH] adapt to new lexer behavior --- src/lib66/parse/parse_get_section.c | 5 +---- src/lib66/parse/parse_key.c | 5 +---- src/lib66/parse/parse_list.c | 14 ++------------ 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/lib66/parse/parse_get_section.c b/src/lib66/parse/parse_get_section.c index 683f9ade..ed18efe6 100644 --- a/src/lib66/parse/parse_get_section.c +++ b/src/lib66/parse/parse_get_section.c @@ -37,12 +37,9 @@ int parse_get_section(lexer_config *acfg, unsigned int *ncfg, char const *str, s cfg.pos = pos ; stack_reset(&stk) ; - if (!lexer(&stk, &cfg)) + if (!lexer(&stk, &cfg) || !stack_close(&stk)) return 0 ; - if (!stack_close(&stk)) - log_warnu_return(LOG_EXIT_ZERO, "stack overflow") ; - if (cfg.found) { ssize_t id = get_enum_by_key(stk.s) ; diff --git a/src/lib66/parse/parse_key.c b/src/lib66/parse/parse_key.c index 27b240cb..45de9386 100644 --- a/src/lib66/parse/parse_key.c +++ b/src/lib66/parse/parse_key.c @@ -24,12 +24,9 @@ int parse_key(stack *key, lexer_config *cfg) { int kid = -1, next = -1 ; - if (!lexer(key, cfg)) + if (!lexer(key, cfg) || !stack_close(key)) return -1 ; - if (!stack_close(key)) - log_warnu_return(LOG_EXIT_LESSONE, "stack overflow") ; - if (cfg->found) { kid = get_enum_by_key(key->s) ; diff --git a/src/lib66/parse/parse_list.c b/src/lib66/parse/parse_list.c index 7fdd9dda..3e731510 100644 --- a/src/lib66/parse/parse_list.c +++ b/src/lib66/parse/parse_list.c @@ -28,19 +28,9 @@ int parse_list(stack *stk) if (!stack_copy_stack(&tmp, stk)) return 0 ; - cfg.str = tmp.s ; cfg.slen = tmp.len ; - stk->len = 0 ; stk->count = 0 ; + stack_reset(stk) ; - while (cfg.pos < cfg.slen) { - - lexer_reset(&cfg) ; - cfg.opos = 0 ; - cfg.cpos = 0 ; - if (!lexer(stk, &cfg)) - return 0 ; - } - - if (!stack_close(stk)) + if (!lexer_trim_with_g(stk, tmp.s, &cfg)) return 0 ; return 1 ; -- GitLab