summaryrefslogtreecommitdiff
path: root/libguile/unif.c
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2005-06-06 17:21:26 +0000
committerMarius Vollmer <mvo@zagadka.de>2005-06-06 17:21:26 +0000
commitcb5773fe72e8c510523fab91eed0d40d3b1beabd (patch)
tree3cffd59619c8b5ce84a993cd848bc3e020969335 /libguile/unif.c
parent10bb8679736173cec7346fd5691fadb22f7bfa2c (diff)
downloadguile-cb5773fe72e8c510523fab91eed0d40d3b1beabd.tar.gz
(scm_array_in_bounds_p): First test for real arrays, then
check for generalized vectors. This ensures that the generalized vector case need only work with zero-origin ranges.
Diffstat (limited to 'libguile/unif.c')
-rw-r--r--libguile/unif.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/libguile/unif.c b/libguile/unif.c
index f8ba5a2e7..1cdc47895 100644
--- a/libguile/unif.c
+++ b/libguile/unif.c
@@ -1136,18 +1136,7 @@ SCM_DEFINE (scm_array_in_bounds_p, "array-in-bounds?", 1, 0, 1,
SCM_VALIDATE_REST_ARGUMENT (args);
- if (scm_is_generalized_vector (v))
- {
- long ind;
-
- if (!scm_is_pair (args))
- SCM_WRONG_NUM_ARGS ();
- ind = scm_to_long (SCM_CAR (args));
- args = SCM_CDR (args);
- res = scm_from_bool (ind >= 0
- && ind < scm_c_generalized_vector_length (v));
- }
- else if (SCM_I_ARRAYP (v) || SCM_I_ENCLOSED_ARRAYP (v))
+ if (SCM_I_ARRAYP (v) || SCM_I_ENCLOSED_ARRAYP (v))
{
size_t k = SCM_I_ARRAY_NDIM (v);
scm_t_array_dim *s = SCM_I_ARRAY_DIMS (v);
@@ -1172,6 +1161,21 @@ SCM_DEFINE (scm_array_in_bounds_p, "array-in-bounds?", 1, 0, 1,
}
}
}
+ else if (scm_is_generalized_vector (v))
+ {
+ /* Since real arrays have been covered above, all generalized
+ vectors are guaranteed to be zero-origin here.
+ */
+
+ long ind;
+
+ if (!scm_is_pair (args))
+ SCM_WRONG_NUM_ARGS ();
+ ind = scm_to_long (SCM_CAR (args));
+ args = SCM_CDR (args);
+ res = scm_from_bool (ind >= 0
+ && ind < scm_c_generalized_vector_length (v));
+ }
else
scm_wrong_type_arg_msg (NULL, 0, v, "array");