summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-06-06 06:32:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-06-06 06:32:19 -0700
commit16397fbdedaa4510bf17b4a27cb67ecb1ee0a3c2 (patch)
tree267fadde5128711d9255116fb18b6a46a43d2f86 /lib.c
parentcce7a7d2bcb1b144d87b42f34fb295ee813eaff2 (diff)
downloadtxr-16397fbdedaa4510bf17b4a27cb67ecb1ee0a3c2.tar.gz
txr-16397fbdedaa4510bf17b4a27cb67ecb1ee0a3c2.tar.bz2
txr-16397fbdedaa4510bf17b4a27cb67ecb1ee0a3c2.zip
Handle structs in list collection operations.
This eliminates the error which occurs when a sequence implemented as a struct is nconced or appended onto. The struct is converted to a list, and so is the object on the right hand side. As a result, more generic sequence code works on structs. * lib.c (list_collect_nconc, list_collect_append): Handle tail of type COBJ by converting to a list, storing that list back in the tail and then destructively tacking onto that the obj operand, also turned into a list.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 8807a189..c734324b 100644
--- a/lib.c
+++ b/lib.c
@@ -803,6 +803,11 @@ loc list_collect_nconc(loc ptail, val obj)
case LSTR:
replace_str(tailobj, obj, t, t);
return ptail;
+ case COBJ:
+ set(ptail, tolist(tailobj));
+ ptail = tail(deref(ptail));
+ set(ptail, tolist(obj));
+ return ptail;
default:
uw_throwf(error_s, lit("cannot nconc ~s to ~s"), obj, tailobj, nao);
}
@@ -833,6 +838,11 @@ loc list_collect_append(loc ptail, val obj)
set(ptail, copy_str(tailobj));
replace_str(deref(ptail), obj, t, t);
return ptail;
+ case COBJ:
+ set(ptail, tolist(tailobj));
+ ptail = tail(deref(ptail));
+ set(ptail, tolist(obj));
+ return ptail;
default:
uw_throwf(error_s, lit("cannot append to ~s"), tailobj, nao);
}