From 6a63a6b32065f6a5839571b378605f875f9c5240 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 6 Feb 2014 00:39:17 -0800 Subject: * eval.c (op_dwim): Gutted down to just a few lines. Basically the dwim operator is just a Lisp-1 version of the call operator now. It doesn't have to do anything funny with non-function objects, since they are callable. * lib.c (chr_str, chr_str_set, vecref, vecref_l): Replace inappropriate internal assertions with error exceptions. * unwind.h (numeric_assert, range_bug_unless): Unused macros removed. --- lib.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 03961597..6798cb4f 100644 --- a/lib.c +++ b/lib.c @@ -2610,7 +2610,9 @@ val chr_str(val str, val ind) index = c_num(ind); } - bug_unless (index >= 0 && length_str_gt(str, ind)); + if (index < 0 || !length_str_gt(str, ind)) + uw_throwf(error_s, lit("chr-str: ~s is out of range for string ~s"), + ind, str, nao); if (lazy_stringp(str)) { lazy_str_force_upto(str, ind); @@ -2629,7 +2631,10 @@ val chr_str_set(val str, val ind, val chr) index = c_num(ind); } - bug_unless (index >= 0 && length_str_gt(str, ind)); + if (index < 0 || !length_str_gt(str, ind)) + uw_throwf(error_s, lit("chr-str-set: ~s is out of range for string ~s"), + ind, str, nao); + if (lazy_stringp(str)) { lazy_str_force_upto(str, ind); @@ -3894,7 +3899,9 @@ val vecref(val vec, val ind) cnum len = c_num(length_vec(vec)); if (index < 0) index = len + index; - range_bug_unless (index >= 0 && index < len); + if (index < 0 || index >= len) + uw_throwf(error_s, lit("vecref: ~s is out of range for vector ~s"), + ind, vec, nao); return vec->v.vec[index]; } @@ -3902,7 +3909,9 @@ val *vecref_l(val vec, val ind) { cnum index = c_num(ind); cnum len = c_num(length_vec(vec)); - range_bug_unless (index >= 0 && index < len); + if (index < 0 || index >= len) + uw_throwf(error_s, lit("vecref: ~s is out of range for vector ~s"), + ind, vec, nao); return vec->v.vec + index; } -- cgit v1.2.3