[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
guile/guile-core/libguile ChangeLog strings.c s...
From: |
Dirk Herrmann |
Subject: |
guile/guile-core/libguile ChangeLog strings.c s... |
Date: |
Thu, 08 Feb 2001 03:40:51 -0800 |
CVSROOT: /cvs
Module name: guile
Changes by: Dirk Herrmann <address@hidden> 01/02/08 03:40:51
Modified files:
guile-core/libguile: ChangeLog strings.c strings.h vectors.c
Log message:
* Fixed parameter checking for make-string.
* Corrected a bug introduced with the last patch.
CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ChangeLog.diff?r1=1.1263&r2=1.1264
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/strings.c.diff?r1=1.47&r2=1.48
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/strings.h.diff?r1=1.26&r2=1.27
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/vectors.c.diff?r1=1.43&r2=1.44
Patches:
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1263
guile/guile-core/libguile/ChangeLog:1.1264
--- guile/guile-core/libguile/ChangeLog:1.1263 Thu Feb 8 02:48:01 2001
+++ guile/guile-core/libguile/ChangeLog Thu Feb 8 03:40:51 2001
@@ -1,5 +1,18 @@
2001-02-08 Dirk Herrmann <address@hidden>
+ * strings.h (SCM_STRING_MAX_LENGTH): New macro.
+
+ * strings.c (scm_makstr, scm_take_str, scm_make_string): Added
+ range checking for the size parameter. Thanks to Martin
+ Grabmueller for the hint.
+
+ (scm_makstr): Reordered string initialization to make interrupt
+ deferring unnecessary.
+
+ * vectors.c (scm_make_vector): Fixed range checking.
+
+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
Index: guile/guile-core/libguile/strings.c
diff -u guile/guile-core/libguile/strings.c:1.47
guile/guile-core/libguile/strings.c:1.48
--- guile/guile-core/libguile/strings.c:1.47 Thu Nov 23 05:54:49 2000
+++ guile/guile-core/libguile/strings.c Thu Feb 8 03:40:51 2001
@@ -124,19 +124,27 @@
}
#undef FUNC_NAME
+
SCM
scm_makstr (long len, int dummy)
+#define FUNC_NAME "scm_makstr"
{
SCM s;
- char *mem = (char *) scm_must_malloc (len + 1, "scm_makstr");
+ char *mem;
+
+ SCM_ASSERT_RANGE (1, scm_long2num (len), len <= SCM_STRING_MAX_LENGTH);
+ mem = (char *) scm_must_malloc (len + 1, FUNC_NAME);
mem[len] = 0;
+
SCM_NEWCELL (s);
SCM_SET_STRING_CHARS (s, mem);
SCM_SET_STRING_LENGTH (s, len);
return s;
}
+#undef FUNC_NAME
+
/* converts C scm_array of strings to SCM scm_list of strings. */
/* If argc < 0, a null terminated scm_array is assumed. */
@@ -164,16 +172,21 @@
made up. */
SCM
scm_take_str (char *s, int len)
+#define FUNC_NAME "scm_take_str"
{
SCM answer;
+
+ SCM_ASSERT_RANGE (2, scm_ulong2num (len), len <= SCM_STRING_MAX_LENGTH);
+
SCM_NEWCELL (answer);
- SCM_DEFER_INTS;
+ SCM_SET_STRING_CHARS (answer, s);
SCM_SET_STRING_LENGTH (answer, len);
scm_done_malloc (len + 1);
- SCM_SET_STRING_CHARS (answer, s);
- SCM_ALLOW_INTS;
+
return answer;
}
+#undef FUNC_NAME
+
/* `s' must be a malloc'd string. See scm_take_str. */
SCM
@@ -208,8 +221,6 @@
}
-
-
SCM_DEFINE (scm_make_string, "make-string", 1, 1, 0,
(SCM k, SCM chr),
"Returns a newly allocated string of\n"
@@ -218,23 +229,33 @@
"STRING are unspecified.\n")
#define FUNC_NAME s_scm_make_string
{
- SCM res;
- register long i;
- SCM_VALIDATE_INUM_MIN_COPY (1,k,0,i);
- res = scm_makstr (i, 0);
- if (!SCM_UNBNDP (chr))
+ if (SCM_INUMP (k))
{
- SCM_VALIDATE_CHAR (2,chr);
- {
- unsigned char *dst = SCM_STRING_UCHARS (res);
- char c = SCM_CHAR (chr);
-
- memset (dst, c, i);
- }
+ long int i = SCM_INUM (k);
+ SCM res;
+
+ SCM_ASSERT_RANGE (1, k, i >= 0);
+
+ res = scm_makstr (i, 0);
+ if (!SCM_UNBNDP (chr))
+ {
+ unsigned char *dst;
+
+ SCM_VALIDATE_CHAR (2, chr);
+
+ dst = SCM_STRING_UCHARS (res);
+ memset (dst, SCM_CHAR (chr), i);
+ }
+
+ return res;
}
- return res;
+ else if (SCM_BIGP (k))
+ SCM_OUT_OF_RANGE (1, k);
+ else
+ SCM_WRONG_TYPE_ARG (1, k);
}
#undef FUNC_NAME
+
SCM_DEFINE (scm_string_length, "string-length", 1, 0, 0,
(SCM string),
Index: guile/guile-core/libguile/strings.h
diff -u guile/guile-core/libguile/strings.h:1.26
guile/guile-core/libguile/strings.h:1.27
--- guile/guile-core/libguile/strings.h:1.26 Thu Nov 23 05:54:49 2000
+++ guile/guile-core/libguile/strings.h Thu Feb 8 03:40:51 2001
@@ -57,6 +57,7 @@
#define SCM_STRING_CHARS(x) ((char *) (SCM_CELL_WORD_1 (x)))
#endif
#define SCM_SET_STRING_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c)))
+#define SCM_STRING_MAX_LENGTH ((1L << 24) - 1)
#define SCM_STRING_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8)
#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), ((l) << 8) +
scm_tc7_string))
Index: guile/guile-core/libguile/vectors.c
diff -u guile/guile-core/libguile/vectors.c:1.43
guile/guile-core/libguile/vectors.c:1.44
--- guile/guile-core/libguile/vectors.c:1.43 Thu Feb 8 02:48:01 2001
+++ guile/guile-core/libguile/vectors.c Thu Feb 8 03:40:51 2001
@@ -275,7 +275,7 @@
if (SCM_INUMP (k))
{
- SCM_ASSERT_RANGE (1, k, k >= 0);
+ SCM_ASSERT_RANGE (1, k, SCM_INUM (k) >= 0);
return scm_c_make_vector (SCM_INUM (k), fill);
}
else if (SCM_BIGP (k))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- guile/guile-core/libguile ChangeLog strings.c s...,
Dirk Herrmann <=