diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-06 00:39:17 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-06 00:39:17 -0800 |
commit | 6a63a6b32065f6a5839571b378605f875f9c5240 (patch) | |
tree | 3ffb3de049fdcefeed5f7a11cab48602729f95c5 /lib.c | |
parent | 87ef0e20b4e9d8f82d061ddc6993d04a2f6eda9d (diff) | |
download | txr-6a63a6b32065f6a5839571b378605f875f9c5240.tar.gz txr-6a63a6b32065f6a5839571b378605f875f9c5240.tar.bz2 txr-6a63a6b32065f6a5839571b378605f875f9c5240.zip |
* 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.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -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; } |