From 6ecb49f5104b89596eb1c5d8bb2c788cd6c39386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 25 Feb 2019 23:56:01 +0100 Subject: Single elemnt lists in components now return their CAR. --- guile_interface.scm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'guile_interface.scm.c') diff --git a/guile_interface.scm.c b/guile_interface.scm.c index fa4f2f5f..725d16e6 100644 --- a/guile_interface.scm.c +++ b/guile_interface.scm.c @@ -47,12 +47,17 @@ SCM_DEFINE (vcomponent_get_attribute, "vcomponent-get-attribute", 2, 0, 0, if (c == NULL) return SCM_BOOL_F; - // TODO returns the car of list if list is one long. SCM llist = SCM_EOL; FOR (LLIST, content_set, v, &c->val) { llist = scm_cons(scm_from_strbuf(&v->key), llist); } - return llist; + + /* returns the car of list if list is one long. */ + if (scm_to_int(scm_length(llist)) == 1) { + return SCM_CAR(llist); + } else { + return llist; + } } SCM_DEFINE (vcomponent_set_attr_x, "vcomponent-set-attribute!", 3, 0, 0, @@ -66,8 +71,6 @@ SCM_DEFINE (vcomponent_set_attr_x, "vcomponent-set-attribute!", 3, 0, 0, content_line* c = get_property (com, key); free(key); - // TODO if list is a value store it as is, else wrap it in a list - // of length one. scm_gc_unprotect_object(c->val.cur->value->key.scm); c->val.cur->value->key.scm = new_value; scm_gc_protect_object(c->val.cur->value->key.scm); -- cgit v1.2.3