aboutsummaryrefslogtreecommitdiff
path: root/guile_interface.scm.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-04 18:31:00 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-04 18:31:00 +0100
commit7bc58226a529293c42e82eba3b37eecf7f5978c7 (patch)
tree63a4db9de4870eb5cc00266ce85755e83966c1ab /guile_interface.scm.c
parentChange vendor attribute from HH to HNH. (diff)
downloadcalp-7bc58226a529293c42e82eba3b37eecf7f5978c7.tar.gz
calp-7bc58226a529293c42e82eba3b37eecf7f5978c7.tar.xz
set-attr! can now add new keys.
Diffstat (limited to 'guile_interface.scm.c')
-rw-r--r--guile_interface.scm.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/guile_interface.scm.c b/guile_interface.scm.c
index 41d13c3c..761bf7c2 100644
--- a/guile_interface.scm.c
+++ b/guile_interface.scm.c
@@ -68,9 +68,22 @@ SCM_DEFINE (vcomponent_set_attr_x, "%vcomponent-set-attribute!", 3, 0, 0,
char* key = scm_to_utf8_stringn(scm_string_upcase(attr), NULL);
content_line* c = get_property (com, key);
+
+ /* Create the position in the TRIE if it doesn't already exist */
+ if (c == NULL) {
+ /* Insert empty key since this allows me to use the helper
+ * function */
+ vcomponent_push_val(com, key, "");
+ c = get_property (com, key);
+ } else {
+ /* If the object already exists it should be protected,
+ * so unprotect it
+ */
+ scm_gc_unprotect_object(c->cur->value->key.scm);
+ }
+
free(key);
- scm_gc_unprotect_object(c->cur->value->key.scm);
c->cur->value->key.scm = new_value;
scm_gc_protect_object(c->cur->value->key.scm);