From 74a547aa407ff8555f40dc38b18dee0bdb708836 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Sun, 15 Mar 2020 14:17:22 +0100 Subject: move key check to symbol evaluation branch --- src/template.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/template.c b/src/template.c index f357d45..a5486df 100644 --- a/src/template.c +++ b/src/template.c @@ -58,16 +58,17 @@ int eval(char *dest, mpc_ast_t* t, struct hashmap *ctx) { if (ctx != NULL && strstr(t->children[2]->tag, "symbol")) { char *key = t->children[2]->contents; value = hashmap_resolve(ctx, key); + + // TODO: Handle unexisting keys + if (value == NULL) { + return 1; + } } else if(strstr(t->children[2]->tag, "number")) { value = t->children[2]->contents; } else if(strstr(t->children[2]->tag, "string")) { value = t->children[2]->children[1]->contents; } - // TODO: Handle unexisting keys - if (value == NULL) { - return 1; - } strcat(dest, value); return 0; } -- cgit v1.2.3