[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
guile/guile-core/libguile ChangeLog vectors.c v...
From: |
Dirk Herrmann |
Subject: |
guile/guile-core/libguile ChangeLog vectors.c v... |
Date: |
Thu, 08 Feb 2001 02:48:02 -0800 |
CVSROOT: /cvs
Module name: guile
Changes by: Dirk Herrmann <address@hidden> 01/02/08 02:48:01
Modified files:
guile-core/libguile: ChangeLog vectors.c vectors.h
Log message:
* Fixed parameter checking for make-vector.
CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ChangeLog.diff?r1=1.1262&r2=1.1263
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/vectors.c.diff?r1=1.42&r2=1.43
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/vectors.h.diff?r1=1.27&r2=1.28
Patches:
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1262
guile/guile-core/libguile/ChangeLog:1.1263
--- guile/guile-core/libguile/ChangeLog:1.1262 Mon Feb 5 18:12:10 2001
+++ guile/guile-core/libguile/ChangeLog Thu Feb 8 02:48:01 2001
@@ -1,3 +1,12 @@
+2001-02-08 Dirk Herrmann <address@hidden>
+
+ * vectors.h (SCM_VECTOR_MAX_LENGTH): New macro.
+
+ * vectors.c (scm_make_vector, scm_c_make_vector): Improved the
+ checking of the size parameter for type correctness and valid
+ range. Thanks to Rob Browning for reporting the problem. Instead
+ of deferring interrupts, scm_remember_upto_here_1 is used.
+
2001-02-05 Keisuke Nishida <address@hidden>
* dump.c (scm_store_cell_object, scm_restore_cell_object): Removed.
Index: guile/guile-core/libguile/vectors.c
diff -u guile/guile-core/libguile/vectors.c:1.42
guile/guile-core/libguile/vectors.c:1.43
--- guile/guile-core/libguile/vectors.c:1.42 Thu Feb 1 20:56:25 2001
+++ guile/guile-core/libguile/vectors.c Thu Feb 8 02:48:01 2001
@@ -270,41 +270,51 @@
"Otherwise the initial contents of each element is unspecified.
(r5rs)")
#define FUNC_NAME s_scm_make_vector
{
- SCM_VALIDATE_INUM_MIN (1, k, 0);
if (SCM_UNBNDP (fill))
fill = SCM_UNSPECIFIED;
- return scm_c_make_vector (SCM_INUM (k), fill);
+
+ if (SCM_INUMP (k))
+ {
+ SCM_ASSERT_RANGE (1, k, k >= 0);
+ return scm_c_make_vector (SCM_INUM (k), fill);
+ }
+ else if (SCM_BIGP (k))
+ SCM_OUT_OF_RANGE (1, k);
+ else
+ SCM_WRONG_TYPE_ARG (1, k);
}
#undef FUNC_NAME
+
SCM
scm_c_make_vector (unsigned long int k, SCM fill)
#define FUNC_NAME s_scm_make_vector
{
SCM v;
- scm_bits_t *velts;
+ scm_bits_t *base;
- SCM_NEWCELL (v);
+ if (k > 0)
+ {
+ unsigned long int j;
+
+ SCM_ASSERT_RANGE (1, scm_ulong2num (k), k <= SCM_VECTOR_MAX_LENGTH);
+
+ base = scm_must_malloc (k * sizeof (scm_bits_t), FUNC_NAME);
+ for (j = 0; j != k; ++j)
+ base[j] = SCM_UNPACK (fill);
+ }
+ else
+ base = NULL;
- velts = (k != 0)
- ? scm_must_malloc (k * sizeof (scm_bits_t), FUNC_NAME)
- : NULL;
-
- SCM_DEFER_INTS;
- {
- unsigned long int j;
-
- for (j = 0; j != k; ++j)
- velts[j] = SCM_UNPACK (fill);
-
- SCM_SET_VECTOR_BASE (v, velts);
- SCM_SET_VECTOR_LENGTH (v, k, scm_tc7_vector);
- }
- SCM_ALLOW_INTS;
+ SCM_NEWCELL (v);
+ SCM_SET_VECTOR_BASE (v, base);
+ SCM_SET_VECTOR_LENGTH (v, k, scm_tc7_vector);
+ scm_remember_upto_here_1 (fill);
return v;
}
#undef FUNC_NAME
+
SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
(SCM v),
Index: guile/guile-core/libguile/vectors.h
diff -u guile/guile-core/libguile/vectors.h:1.27
guile/guile-core/libguile/vectors.h:1.28
--- guile/guile-core/libguile/vectors.h:1.27 Thu Feb 1 20:56:25 2001
+++ guile/guile-core/libguile/vectors.h Thu Feb 8 02:48:01 2001
@@ -54,6 +54,7 @@
#define SCM_VECTORP(x) (SCM_NIMP (x) && (SCM_TYP7S (x) == scm_tc7_vector))
#define SCM_VECTOR_BASE(x) ((scm_bits_t *) SCM_CELL_WORD_1 (x))
#define SCM_SET_VECTOR_BASE(v, b) (SCM_SET_CELL_WORD_1 ((v), (b)))
+#define SCM_VECTOR_MAX_LENGTH ((1L << 24) - 1)
#define SCM_VECTOR_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8)
#define SCM_SET_VECTOR_LENGTH(v, l, t) (SCM_SET_CELL_WORD_0 ((v), ((l) << 8) +
(t)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- guile/guile-core/libguile ChangeLog vectors.c v...,
Dirk Herrmann <=