From 90bda5c939db3a65a7c9dc1347855b4a1def1f0a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 25 Jun 2019 07:17:48 -0700 Subject: Handle buffers in list collector functions. * lib.c (nullify, list_collect, list_collect_nconc, list_collect_append, list_collect_nreconc, list_collect_revappend): Handle buffer type. --- lib.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index e133c854..7614aab2 100644 --- a/lib.c +++ b/lib.c @@ -1008,6 +1008,8 @@ val nullify(val seq) return if3(length_str_gt(seq, zero), seq, nil); case VEC: return if3(length_vec(seq) != zero, seq, nil); + case BUF: + return if3(length_buf(seq) != zero, seq, nil); case COBJ: if (obj_struct_p(seq)) { val nullify_meth = maybe_slot(seq, nullify_s); @@ -1047,6 +1049,9 @@ loc list_collect(loc ptail, val obj) case LSTR: replace_str(tailobj, items, t, t); return ptail; + case BUF: + replace_buf(tailobj, items, t, t); + return ptail; case COBJ: if (tailobj->co.cls == carray_s) { carray_replace(tailobj, items, t, t); @@ -1082,6 +1087,9 @@ loc list_collect_nconc(loc ptail, val obj) case LSTR: replace_str(tailobj, obj, t, t); return ptail; + case BUF: + replace_buf(tailobj, obj, t, t); + return ptail; case COBJ: set(ptail, tolist(tailobj)); ptail = tail(deref(ptail)); @@ -1117,6 +1125,10 @@ loc list_collect_append(loc ptail, val obj) set(ptail, copy_str(tailobj)); replace_str(deref(ptail), obj, t, t); return ptail; + case BUF: + set(ptail, copy_buf(tailobj)); + replace_buf(deref(ptail), obj, t, t); + return ptail; case COBJ: set(ptail, tolist(tailobj)); ptail = tail(deref(ptail)); @@ -1154,6 +1166,9 @@ loc list_collect_nreconc(loc ptail, val obj) case LSTR: replace_str(tailobj, rev, t, t); return ptail; + case BUF: + replace_buf(tailobj, obj, t, t); + return ptail; default: uw_throwf(error_s, lit("cannot nconc ~s to ~s"), obj, tailobj, nao); } @@ -1214,6 +1229,10 @@ loc list_collect_revappend(loc ptail, val obj) set(ptail, copy_str(tailobj)); replace_str(deref(ptail), reverse(obj), t, t); return ptail; + case BUF: + set(ptail, copy_buf(tailobj)); + replace_buf(deref(ptail), reverse(obj), t, t); + return ptail; default: uw_throwf(error_s, lit("cannot append to ~s"), tailobj, nao); } -- cgit v1.2.3