From 6a48e98582b4b8025156fe0dc467a45b17dd4f7a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 11 May 2015 07:51:56 -0700 Subject: Handle vectors and strings in rplaca and rplacd. * lib.c (rplaca, rplacd): Use refset and replace respectively to handle vectors and strings. Adjust type mismatch error message. --- ChangeLog | 8 ++++++++ lib.c | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c778a0e2..9e1b77c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-05-11 Kaz Kylheku + + Handle vectors and strings in rplaca and rplacd. + + * lib.c (rplaca, rplacd): Use refset and replace + respectively to handle vectors and strings. + Adjust type mismatch error message. + 2015-05-11 Kaz Kylheku * lib.c (chr_str_set): Check for literal strings. diff --git a/lib.c b/lib.c index 46e445ca..a1dd429e 100644 --- a/lib.c +++ b/lib.c @@ -283,8 +283,13 @@ val rplaca(val cons, val new_car) case LCONS: set(mkloc(cons->lc.car, cons), new_car); return cons; + case VEC: + case STR: + case LSTR: + refset(cons, zero, new_car); + return cons; default: - type_mismatch(lit("~s is not a cons"), cons, nao); + type_mismatch(lit("rplaca: cannot modify ~s"), cons, nao); } } @@ -297,8 +302,13 @@ val rplacd(val cons, val new_cdr) case LCONS: set(mkloc(cons->lc.cdr, cons), new_cdr); return cons; + case VEC: + case STR: + case LSTR: + replace(cons, new_cdr, one, t); + return cons; default: - type_mismatch(lit("~s is not a cons"), cons, nao); + type_mismatch(lit("rplacd: cannot modify ~s"), cons, nao); } } -- cgit v1.2.3