summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2000-06-30 09:48:25 +0000
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2000-06-30 09:48:25 +0000
commitfdf25853e190c086e75fce727c657e27e224eb42 (patch)
tree3a45348e349fea560c84e1fe3146243730c12ddb
parent627df12801ed865ecc01eae52762b2e2338022a7 (diff)
downloadguile-fdf25853e190c086e75fce727c657e27e224eb42.tar.gz
* Fix range checks of SCM_VALIDATE* macros.
-rw-r--r--libguile/ChangeLog11
-rw-r--r--libguile/validate.h10
2 files changed, 16 insertions, 5 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 9e881d41c..31cd6ea3f 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,14 @@
+2000-06-30 Dirk Herrmann <D.Herrmann@tu-bs.de>
+
+ * validate.h (SCM_VALIDATE_INUM_MIN_COPY,
+ SCM_VALIDATE_INUM_MIN_DEF_COPY, SCM_VALIDATE_INUM_RANGE_COPY):
+ Perform all range checks based on the input value. The former way
+ of using the value that is assigned to the target variable fails
+ if the assignment to the target variable itself can change the
+ value because of type conversion.
+
+ (SCM_ASSERT_RANGE): Use scm_out_of_range to signal range errors.
+
2000-06-30 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
* gc.c (scm_gc_for_newcell): Behave gracefully also if scm_igc
diff --git a/libguile/validate.h b/libguile/validate.h
index 8ce49ca68..9889757d8 100644
--- a/libguile/validate.h
+++ b/libguile/validate.h
@@ -1,4 +1,4 @@
-/* $Id: validate.h,v 1.12 2000-06-05 11:39:46 dirk Exp $ */
+/* $Id: validate.h,v 1.13 2000-06-30 09:48:25 dirk Exp $ */
/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
@@ -83,7 +83,7 @@
do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
#define SCM_ASSERT_RANGE(pos, arg, f) \
- do { SCM_ASSERT (f, arg, SCM_OUTOFRANGE, FUNC_NAME); } while (0)
+ do { if (!(f)) scm_out_of_range (FUNC_NAME, arg); } while (0)
#define SCM_MUST_MALLOC_TYPE(type) \
((type *) scm_must_malloc (sizeof (type), FUNC_NAME))
@@ -212,8 +212,8 @@
#define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \
do { \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
+ SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
cvar = SCM_INUM (k); \
- SCM_ASSERT_RANGE (pos, k, (cvar >= min)); \
} while (0)
#define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \
@@ -221,8 +221,8 @@
if (SCM_UNBNDP (k)) \
k = SCM_MAKINUM (default); \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
+ SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
cvar = SCM_INUM (k); \
- SCM_ASSERT_RANGE (pos, k, (cvar >= min)); \
} while (0)
#define SCM_VALIDATE_INUM_DEF(pos, k, default) \
@@ -257,8 +257,8 @@
#define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \
do { \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
+ SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \
cvar = SCM_INUM (k); \
- SCM_ASSERT_RANGE (pos, k, cvar >= low && cvar < high); \
} while (0)
#define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE (pos, scm, NULLP)