From 35c4f119ca188fd9e90a2bbada864f9d121459ba Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 25 Jan 2016 04:46:19 +0100 Subject: renderer: fix bug when 'if' evals to false after 'if' evals to true --- src/renderer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/renderer.c') diff --git a/src/renderer.c b/src/renderer.c index 0f5d10a..5e07b0c 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -134,7 +134,6 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing char *defined = NULL; unsigned int if_count = 0; - unsigned int if_skip = 0; b_slist_t *foreach_var = NULL; b_slist_t *foreach_var_start = NULL; @@ -237,6 +236,7 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing case BLOGC_TEMPLATE_IF_STMT: case BLOGC_TEMPLATE_IFDEF_STMT: + if_count = 0; defined = NULL; if (stmt->value != NULL) defined = blogc_format_variable(stmt->value, config, @@ -283,7 +283,6 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing evaluate = true; } if (!evaluate) { - if_skip = if_count; // at this point we can just skip anything, counting the // number of 'if's, to know how many 'endif's we need to @@ -299,11 +298,11 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing continue; } if (stmt->type == BLOGC_TEMPLATE_ENDIF_STMT) { - if (if_count > if_skip) { + if (if_count > 0) { if_count--; continue; } - if (if_count == if_skip) + if (if_count == 0) break; } } @@ -314,7 +313,8 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing break; case BLOGC_TEMPLATE_ENDIF_STMT: - if_count--; + if (if_count > 0) + if_count--; break; case BLOGC_TEMPLATE_FOREACH_STMT: -- cgit v1.2.3-18-g5258