From 37071ccd8e03de74c91dad2aa59ec1717797ad4e Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 8 Nov 2009 20:16:25 +0100 Subject: [PATCH] ifblock objects: fix bug for sub-object parsing ifblocks When dropping the ifblock field of struct text_object, I short-sightedly reused the sub field for holding the pointer to the matching else/endif. This however doesn't work for objects parsing their own object list, as they need the sub field for themselfs. Since we have it, simply reuse the special_data field instead and hope there won't ever be an object which is both special and ifblock. ;) --- src/conky.c | 2 +- src/text_object.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conky.c b/src/conky.c index c1cd1bc8..133a9e70 100644 --- a/src/conky.c +++ b/src/conky.c @@ -797,7 +797,7 @@ void generate_text_internal(char *p, int p_max_size, */ #define DO_JUMP { \ DBGP2("jumping"); \ - obj = obj->sub; \ + obj = obj->special_data; \ } #define OBJ(a) break; case OBJ_##a: diff --git a/src/text_object.c b/src/text_object.c index c28bc429..3b0fb424 100644 --- a/src/text_object.c +++ b/src/text_object.c @@ -107,7 +107,7 @@ static int push_ifblock(struct ifblock_stack_obj **ifblock_stack_top, case IFBLOCK_ENDIF: if (!(*ifblock_stack_top)) CRIT_ERR(NULL, NULL, "got an endif without matching if"); - (*ifblock_stack_top)->obj->sub = obj; + (*ifblock_stack_top)->obj->special_data = obj; /* if there's some else in between, remove and free it */ if ((*ifblock_stack_top)->type == IFBLOCK_ELSE) { stackobj = *ifblock_stack_top; @@ -122,7 +122,7 @@ static int push_ifblock(struct ifblock_stack_obj **ifblock_stack_top, case IFBLOCK_ELSE: if (!(*ifblock_stack_top)) CRIT_ERR(NULL, NULL, "got an else without matching if"); - (*ifblock_stack_top)->obj->sub = obj; + (*ifblock_stack_top)->obj->special_data = obj; /* fall through */ case IFBLOCK_IF: stackobj = malloc(sizeof(struct ifblock_stack_obj));