diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-11-20 19:56:44 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-11-20 19:56:44 -0800 |
commit | b769f987e089c4b5312b607f973bfe20e3c14ade (patch) | |
tree | 3d6db316309186718e6f9a6485d0b8805c00b1f5 | |
parent | 68de493c2e7500fbc9df94605ff79739c51c3759 (diff) | |
download | txr-b769f987e089c4b5312b607f973bfe20e3c14ade.tar.gz txr-b769f987e089c4b5312b607f973bfe20e3c14ade.tar.bz2 txr-b769f987e089c4b5312b607f973bfe20e3c14ade.zip |
buffers: support list operations.
* lib.c (car, cdr, rplaca, rplacd, make_like): Handle
BUF type.
-rw-r--r-- | lib.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -539,6 +539,10 @@ val car(val cons) if (zerop(length_str(cons))) return nil; return chr_str(cons, zero); + case BUF: + if (zerop(length_buf(cons))) + return nil; + return buf_get_uchar(cons, zero); case COBJ: if (obj_struct_p(cons)) { { @@ -581,6 +585,10 @@ val cdr(val cons) if (le(length(cons), one)) return nil; return sub(cons, one, t); + case BUF: + if (le(length_buf(cons), one)) + return nil; + return sub_buf(cons, one, nil); case COBJ: if (obj_struct_p(cons)) { { @@ -613,6 +621,9 @@ val rplaca(val cons, val new_car) case LSTR: refset(cons, zero, new_car); return cons; + case BUF: + buf_put_uchar(cons, zero, new_car); + return cons; default: if (structp(cons)) { { @@ -648,6 +659,7 @@ val rplacd(val cons, val new_cdr) case VEC: case STR: case LSTR: + case BUF: replace(cons, new_cdr, one, t); return cons; default: @@ -978,6 +990,12 @@ val make_like(val list, val thatobj) if (is_chr(car(list))) return cat_str(list, nil); break; + case BUF: + if (!list) + return make_buf(zero, zero, zero); + if (integerp(car(list))) + return buf_list(list); + break; case COBJ: if (obj_struct_p(thatobj)) { val from_list_meth = get_special_slot(thatobj, from_list_m); |