From 556d75dbb84a1f6cd7c98f75fb794904581ed968 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 29 Sep 2004 17:58:39 +0000 Subject: [PATCH] (SCM_STRING_CHARS): Explicitely reject read-only strings with an error message that blames SCM_STRING_CHARS. --- libguile/strings.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libguile/strings.c b/libguile/strings.c index 6a69124ad..47e7886f8 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -979,6 +979,12 @@ scm_i_get_substring_spec (size_t len, #if SCM_ENABLE_DEPRECATED +/* When these definitions are removed, it becomes reasonable to use + read-only strings for string literals. For that, change the reader + to create string literals with scm_c_substring_read_only instead of + with scm_c_substring_copy. +*/ + int SCM_STRINGP (SCM str) { @@ -1004,6 +1010,15 @@ SCM_STRING_CHARS (SCM str) "SCM_STRING_CHARS does not work with shared substrings.", SCM_EOL); + /* We explicitely test for read-only strings to produce a better + error message. + */ + + if (IS_RO_STRING (str)) + scm_misc_error (NULL, + "SCM_STRING_CHARS does not work with read-only strings.", + SCM_EOL); + /* The following is still wrong, of course... */ chars = scm_i_string_writable_chars (str);