1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 19:50:24 +02:00

(SCM_STRING_CHARS): Explicitely reject read-only strings with an error

message that blames SCM_STRING_CHARS.
This commit is contained in:
Marius Vollmer 2004-09-29 17:58:39 +00:00
parent 81ae25da8c
commit 556d75dbb8

View file

@ -979,6 +979,12 @@ scm_i_get_substring_spec (size_t len,
#if SCM_ENABLE_DEPRECATED #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 int
SCM_STRINGP (SCM str) SCM_STRINGP (SCM str)
{ {
@ -1004,6 +1010,15 @@ SCM_STRING_CHARS (SCM str)
"SCM_STRING_CHARS does not work with shared substrings.", "SCM_STRING_CHARS does not work with shared substrings.",
SCM_EOL); 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... /* The following is still wrong, of course...
*/ */
chars = scm_i_string_writable_chars (str); chars = scm_i_string_writable_chars (str);