From 2e83ff05c53670ed7d758d5189b9a964bc28dd4a Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 8 Nov 2009 14:42:04 +0100 Subject: [PATCH] text object list: allow appending a list of objects --- src/text_object.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/text_object.c b/src/text_object.c index 704905ff..fce1156e 100644 --- a/src/text_object.c +++ b/src/text_object.c @@ -50,15 +50,16 @@ void gen_free_opaque(struct text_object *obj) * (this works in BOTH directions) */ -/* append an object to the given root object's list */ +/* append an object or list of objects to the given root object's list */ int append_object(struct text_object *root, struct text_object *obj) { struct text_object *end; + /* hook in start of list to append */ end = root->prev; obj->prev = end; - obj->next = NULL; + /* update pointers of the list to append to */ if (end) { if (end->next) CRIT_ERR(NULL, NULL, "huston, we have a lift-off"); @@ -66,7 +67,12 @@ int append_object(struct text_object *root, struct text_object *obj) } else { root->next = obj; } + + /* find end of appended list to point root->prev there */ + while (obj->next) + obj = obj->next; root->prev = obj; + return 0; }