summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-27 15:27:11 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-27 15:27:11 -0800
commit480509f85351f4f3ede9c3bf219f6d359d3f8970 (patch)
treed087835766b245e84c0633b3373d452f811c90ff
parent5bb09860276ee5a209abe526c922b838c01af549 (diff)
downloadtxr-480509f85351f4f3ede9c3bf219f6d359d3f8970.tar.gz
txr-480509f85351f4f3ede9c3bf219f6d359d3f8970.tar.bz2
txr-480509f85351f4f3ede9c3bf219f6d359d3f8970.zip
* eval.c (dwim_loc, op_dwim): Relax the requirement on hash
indexing arguments. The default value can be omitted, defaulting to nil.
-rw-r--r--ChangeLog6
-rw-r--r--eval.c8
2 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f64592f..adb74fc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-01-27 Kaz Kylheku <kaz@kylheku.com>
+ * eval.c (dwim_loc, op_dwim): Relax the requirement on hash
+ indexing arguments. The default value can be omitted,
+ defaulting to nil.
+
+2012-01-27 Kaz Kylheku <kaz@kylheku.com>
+
* hash.c (hash_begin): Missing type check added, otherwise
passing in an object that is not a hash results in corruption
or crashing behavior.
diff --git a/eval.c b/eval.c
index 8ae828fe..595a3fc8 100644
--- a/eval.c
+++ b/eval.c
@@ -737,8 +737,8 @@ static val *dwim_loc(val form, val env, val op, val newval, val *retval)
{
if (hashp(obj)) {
val new_p, *loc;
- if (length(args) != two)
- eval_error(form, lit("[~s ...]: hash indexing needs two args"),
+ if (lt(length(args),two))
+ eval_error(form, lit("[~s ...]: hash indexing needs at least one arg"),
obj, nao);
loc = gethash_l(obj, first(args), &new_p);
if (new_p)
@@ -1002,8 +1002,8 @@ static val op_dwim(val form, val env)
case COBJ:
{
if (hashp(obj)) {
- if (length(args) != two)
- eval_error(form, lit("[~s ...]: hash indexing needs two args"),
+ if (lt(length(args), two))
+ eval_error(form, lit("[~s ...]: hash indexing needs at least one arg"),
obj, nao);
return gethash_n(obj, first(args), second(args));
}