[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile: What's wrong with this?
From: |
Mark H Weaver |
Subject: |
Re: Guile: What's wrong with this? |
Date: |
Wed, 04 Jan 2012 18:19:35 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Bruce Korb <address@hidden> writes:
>> ERROR: In procedure string-upcase:
>> ERROR: string is read-only: ""
>> Scheme evaluation error. AutoGen ABEND-ing in template
>> confmacs.tlib on line 209
>> Failing Guile command: = = = = =
>>
>> (set! tmp-text (get "act-text"))
>> (set! TMP-text (string-upcase tmp-text))
>
> What in heck is string-upcase doing trying to write to its input string?
> Why was the string returned by ag_scm_get() (the function bound to "get")
> an immutable string anyway?
Good questions indeed. I spent a bunch of time investigating this, and
found some bugs that might have caused this problem, although I'm not
certain.
Bruce: Can you please see if the patch below fixes this problem?
Mike: Would you be willing to review this (very small) patch to see if
it makes sense to you? I'd like a second opinion from someone familiar
with that subsystem before I commit it.
Thanks,
Mark
>From a8da72937ff4d04e8d39531773cc05e676b2be1c Mon Sep 17 00:00:00 2001
From: Mark H Weaver <address@hidden>
Date: Wed, 4 Jan 2012 17:59:27 -0500
Subject: [PATCH] Fix bugs related to mutation-sharing substrings
* libguile/strings.c (scm_i_is_narrow_string, scm_i_try_narrow_string,
scm_i_string_set_x): Check to see if the provided string is a
mutation-sharing substring, and do the right thing in that case.
Previously, if such a string was passed to these functions, they would
behave very badly: while trying to fetch and/or mutate the cell
containing the stringbuf, they were actually fetching or mutating the
cell containing original shared string. That's because
mutation-sharing substring store the original string in CELL_1,
whereas all other strings store the stringbuf there.
---
libguile/strings.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/libguile/strings.c b/libguile/strings.c
index 666a951..1628aee 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -436,6 +436,9 @@ scm_i_string_length (SCM str)
int
scm_i_is_narrow_string (SCM str)
{
+ if (IS_SH_STRING (str))
+ str = SH_STRING_STRING (str);
+
return !STRINGBUF_WIDE (STRING_STRINGBUF (str));
}
@@ -446,6 +449,9 @@ scm_i_is_narrow_string (SCM str)
int
scm_i_try_narrow_string (SCM str)
{
+ if (IS_SH_STRING (str))
+ str = SH_STRING_STRING (str);
+
SET_STRING_STRINGBUF (str, narrow_stringbuf (STRING_STRINGBUF (str)));
return scm_i_is_narrow_string (str);
@@ -664,6 +670,12 @@ scm_i_string_strcmp (SCM sstr, size_t start_x, const char
*cstr)
void
scm_i_string_set_x (SCM str, size_t p, scm_t_wchar chr)
{
+ if (IS_SH_STRING (str))
+ {
+ p += STRING_START (str);
+ str = SH_STRING_STRING (str);
+ }
+
if (chr > 0xFF && scm_i_is_narrow_string (str))
SET_STRING_STRINGBUF (str, wide_stringbuf (STRING_STRINGBUF (str)));
--
1.7.5.4
- Re: Guile: What's wrong with this?, (continued)
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Ian Price, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?,
Mark H Weaver <=
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Fixed string corruption bugs (was Guile: What's wrong with this?), Mark H Weaver, 2012/01/07
- Re: Fixed string corruption bugs, Andy Wingo, 2012/01/07
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04