mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-23 12:00:21 +02:00
Revert "Make literal strings (i.e., returned by `read') read-only."
This reverts commit be5c4a82ab
.
The rationale is that `read' must return mutable strings, as reported
by szgyg <szgyg@ludens.elte.hu>.
This commit is contained in:
parent
097158c936
commit
4b600701b9
5 changed files with 13 additions and 38 deletions
|
@ -514,7 +514,7 @@ scm_read_string (int chr, SCM port)
|
|||
else
|
||||
str = (str == SCM_BOOL_F) ? scm_nullstr : str;
|
||||
|
||||
return scm_i_make_read_only_string (str);
|
||||
return str;
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
|
|
@ -217,12 +217,6 @@ get_str_buf_start (SCM *str, SCM *buf, size_t *start)
|
|||
*buf = STRING_STRINGBUF (*str);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_i_make_read_only_string (SCM str)
|
||||
{
|
||||
return scm_i_substring_read_only (str, 0, STRING_LENGTH (str));
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_i_substring (SCM str, size_t start, size_t end)
|
||||
{
|
||||
|
@ -240,28 +234,15 @@ scm_i_substring (SCM str, size_t start, size_t end)
|
|||
SCM
|
||||
scm_i_substring_read_only (SCM str, size_t start, size_t end)
|
||||
{
|
||||
SCM result;
|
||||
|
||||
if (SCM_UNLIKELY (STRING_LENGTH (str) == 0))
|
||||
/* We want the empty string to be `eq?' with the read-only empty
|
||||
string. */
|
||||
result = str;
|
||||
else
|
||||
{
|
||||
SCM buf;
|
||||
size_t str_start;
|
||||
|
||||
get_str_buf_start (&str, &buf, &str_start);
|
||||
scm_i_pthread_mutex_lock (&stringbuf_write_mutex);
|
||||
SET_STRINGBUF_SHARED (buf);
|
||||
scm_i_pthread_mutex_unlock (&stringbuf_write_mutex);
|
||||
|
||||
result = scm_double_cell (RO_STRING_TAG, SCM_UNPACK (buf),
|
||||
(scm_t_bits) str_start + start,
|
||||
(scm_t_bits) end - start);
|
||||
}
|
||||
|
||||
return result;
|
||||
SCM buf;
|
||||
size_t str_start;
|
||||
get_str_buf_start (&str, &buf, &str_start);
|
||||
scm_i_pthread_mutex_lock (&stringbuf_write_mutex);
|
||||
SET_STRINGBUF_SHARED (buf);
|
||||
scm_i_pthread_mutex_unlock (&stringbuf_write_mutex);
|
||||
return scm_double_cell (RO_STRING_TAG, SCM_UNPACK(buf),
|
||||
(scm_t_bits)str_start + start,
|
||||
(scm_t_bits) end - start);
|
||||
}
|
||||
|
||||
SCM
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#ifndef SCM_STRINGS_H
|
||||
#define SCM_STRINGS_H
|
||||
|
||||
/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -152,7 +152,6 @@ SCM_API void scm_i_get_substring_spec (size_t len,
|
|||
SCM start, size_t *cstart,
|
||||
SCM end, size_t *cend);
|
||||
SCM_API SCM scm_i_take_stringbufn (char *str, size_t len);
|
||||
SCM_API SCM scm_i_make_read_only_string (SCM str);
|
||||
|
||||
/* deprecated stuff */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue