From c6cd8acac9f6c6916aded21ea1e82d430036d04d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 3 May 2015 21:34:14 -0700 Subject: Deal with bad quote syntax. * eval.c (op_quote): Throw error on bad syntax. * lib.c (obj_print, obj_pprint): Do not hide bad quote syntax using ' notation; print it using ordinary notation. --- ChangeLog | 9 +++++++++ eval.c | 4 ++++ lib.c | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96aee8ce..7d06a0ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-05-03 Kaz Kylheku + + Deal with bad quote syntax. + + * eval.c (op_quote): Throw error on bad syntax. + + * lib.c (obj_print, obj_pprint): Do not hide bad quote syntax + using ' notation; print it using ordinary notation. + 2015-05-01 Kaz Kylheku Move initialization calls to more suitable place. diff --git a/eval.c b/eval.c index 0149c764..87a6b875 100644 --- a/eval.c +++ b/eval.c @@ -1102,6 +1102,10 @@ static val eval_prog1(val forms, val env, val ctx_form) static val op_quote(val form, val env) { + val d = cdr(form); + + if (!consp(d) || cdr(d)) + eval_error(form, lit("bad quote syntax"), nao); return second(form); } diff --git a/lib.c b/lib.c index 6f82063a..0503d615 100644 --- a/lib.c +++ b/lib.c @@ -6700,7 +6700,7 @@ val obj_print(val obj, val out) { val sym = car(obj); - if (sym == quote_s) { + if (sym == quote_s && consp(cdr(obj)) && !(cdr(cdr(obj)))) { put_char(chr('\''), out); obj_print(second(obj), out); } else if (sym == sys_qquote_s) { @@ -6894,7 +6894,7 @@ val obj_pprint(val obj, val out) { val sym = car(obj); - if (sym == quote_s) { + if (sym == quote_s && consp(cdr(obj)) && !(cdr(cdr(obj)))) { put_char(chr('\''), out); obj_print(second(obj), out); } else if (sym == sys_qquote_s) { -- cgit v1.2.3