summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-11 19:47:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-11 19:47:32 -0700
commitc54df81f05e622bd3ce6daa0bc4ba5d3999f958d (patch)
treeb926c2b5cab254dcb3d783bd3fcb50afa79ec6b3 /lib.c
parent2ec0f6e63f9c42750f09af4a7f03be832a2ca28a (diff)
downloadtxr-c54df81f05e622bd3ce6daa0bc4ba5d3999f958d.tar.gz
txr-c54df81f05e622bd3ce6daa0bc4ba5d3999f958d.tar.bz2
txr-c54df81f05e622bd3ce6daa0bc4ba5d3999f958d.zip
buffers: allow sub operation.
* buf.c (sub_buf): New function. * buf.h (sub_buf): Declared. * lib.c (sub): Hook in BUF type. (replace): Diagnose BUF specially as unsupported.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index e3e1909e..1794fa99 100644
--- a/lib.c
+++ b/lib.c
@@ -9996,6 +9996,8 @@ val sub(val seq, val from, val to)
return sub_str(seq, from, to);
case VEC:
return sub_vec(seq, from, to);
+ case BUF:
+ return sub_buf(seq, from, to);
case COBJ:
if (seq->co.cls == carray_s)
return carray_sub(seq, from, to);
@@ -10097,6 +10099,8 @@ val refset(val seq, val ind, val newval)
val replace(val seq, val items, val from, val to)
{
+ val self = lit("replace");
+
switch (type(seq)) {
case NIL:
case CONS:
@@ -10114,8 +10118,10 @@ val replace(val seq, val items, val from, val to)
if (obj_struct_p(seq))
return replace_obj(seq, items, from, to);
/* fallthrough */
+ case BUF:
+ type_mismatch(lit("~a: operation doesn't support buf type"), self, nao);
default:
- type_mismatch(lit("replace: ~s is not a sequence"), seq, nao);
+ type_mismatch(lit("~a: ~s is not a sequence"), self, seq, nao);
}
}