tmpl

Simple key-value templator
git clone https://git.sinitax.com/sinitax/tmpl
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 99ffc24d81679671bee0597b2b3572e0f81574e3
parent 668a02b190517cb347d3dab167f2d2449043efa7
Author: Louis Burda <quent.burda@gmail.com>
Date:   Wed, 21 Jun 2023 02:19:30 +0200

fixup! Fix ifeq with undefined variables

Diffstat:
Mmain.c | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/main.c b/main.c @@ -106,14 +106,12 @@ template(char *line) stack[stack_top].active = 0; stack[stack_top].type = IFEQ; if (!stack_top || stack[stack_top-1].active) { + sep = strchr(line + 6, ' '); + if (!sep) die("invalid #ifeq\n%lu: %s", lineno, line); + *sep = '\0'; value = getvar(line + 6); - if (value) { - sep = strchr(line + 6, ' '); - if (!sep) die("invalid #ifeq\n%lu: %s", - lineno, line); - if (!strcmp(value, sep + 1)) - stack[stack_top].active = 1; - } + if (value && !strcmp(value, sep + 1)) + stack[stack_top].active = 1; } stack_top++; } else if (!strcmp(line, "#else")) {