From 4c6d387b73dca86caed48b1e786c5c1bc2c4716b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 25 Mar 2014 21:01:42 -0700 Subject: * eval.c (expand_quasi): Bugfix: incorrect logic, failing to macro-expand the embedded forms in a quasiliteral except when they are the very first item. --- ChangeLog | 6 ++++++ eval.c | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ae8a0d2..2ba9aa05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-03-25 Kaz Kylheku + + * eval.c (expand_quasi): Bugfix: incorrect logic, failing + to macro-expand the embedded forms in a quasiliteral except + when they are the very first item. + 2014-03-25 Kaz Kylheku * parser.y (yybadtoken): Add missing cases for new token diff --git a/eval.c b/eval.c index c502800f..5c783371 100644 --- a/eval.c +++ b/eval.c @@ -2220,22 +2220,25 @@ static val expand_quasi(val quasi_forms, val menv) val form = first(quasi_forms); val form_ex = form; - if (atom(form)) { - form_ex = form; - } else { + if (consp(form)) { val sym = car(form); if (sym == expr_s) { val expr_ex = expand(rest(form), menv); if (expr_ex != rest(form)) form_ex = rlcp(cons(sym, expr_ex), form); - } + } } - if (form != form_ex) - return rlcp(cons(form_ex, expand_quasi(rest(quasi_forms), menv)), - quasi_forms); - return quasi_forms; + { + val rest_forms = rest(quasi_forms); + val rest_ex = expand_quasi(rest_forms, menv); + + if (form == form_ex && rest_ex == rest_forms) + return quasi_forms; + + return rlcp(cons(form_ex, rest_ex), quasi_forms); + } } } -- cgit v1.2.3