summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-13 08:26:35 +0000
committermichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-13 08:26:35 +0000
commit449f885d62984e2893bcb30258cf04cd67f07559 (patch)
tree583ee779b311227e2026aeb8af0baf249260d764 /string.c
parent8b598af61138988487bef40800ea419cbc74149c (diff)
downloadruby-449f885d62984e2893bcb30258cf04cd67f07559.tar.gz
Fix-Addons [ruby-core:483] with corrections from [ruby-core:484]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/string.c b/string.c
index 60d0cce202..161c8a9894 100644
--- a/string.c
+++ b/string.c
@@ -222,6 +222,7 @@ rb_str_shared_replace(str, str2)
RSTRING(str)->ptr = 0;
RSTRING(str)->len = 0;
RSTRING(str)->aux.capa = 0;
+ FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
return;
}
RSTRING(str)->ptr = RSTRING(str2)->ptr;
@@ -231,6 +232,7 @@ rb_str_shared_replace(str, str2)
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
else {
+ FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
RSTRING(str)->aux.capa = RSTRING(str2)->aux.capa;
}
RSTRING(str2)->ptr = 0; /* abandon str2 */
@@ -632,13 +634,11 @@ VALUE
rb_str_append(str, str2)
VALUE str, str2;
{
- long len;
-
- StringValue(str2);
rb_str_modify(str);
+ StringValue(str2);
if (RSTRING(str2)->len > 0) {
if (FL_TEST(str, STR_ASSOC)) {
- len = RSTRING(str)->len+RSTRING(str2)->len;
+ long len = RSTRING(str)->len+RSTRING(str2)->len;
REALLOC_N(RSTRING(str)->ptr, char, len+1);
memcpy(RSTRING(str)->ptr + RSTRING(str)->len,
RSTRING(str2)->ptr, RSTRING(str2)->len);
@@ -1636,7 +1636,7 @@ rb_str_replace(str, str2)
}
RSTRING(str)->len = RSTRING(str2)->len;
RSTRING(str)->ptr = RSTRING(str2)->ptr;
- FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
+ FL_SET(str, ELTS_SHARED);
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
else {
@@ -1644,7 +1644,7 @@ rb_str_replace(str, str2)
rb_str_resize(str, RSTRING(str2)->len);
memcpy(RSTRING(str)->ptr, RSTRING(str2)->ptr, RSTRING(str2)->len);
if (FL_TEST(str2, STR_ASSOC)) {
- FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
+ FL_SET(str, STR_ASSOC);
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
}
@@ -2305,6 +2305,7 @@ rb_str_delete_bang(argc, argv, str)
if (argc < 1) {
rb_raise(rb_eArgError, "wrong number of arguments");
}
+ rb_str_modify(str);
for (i=0; i<argc; i++) {
VALUE s = argv[i];
@@ -2313,7 +2314,6 @@ rb_str_delete_bang(argc, argv, str)
init = 0;
}
- rb_str_modify(str);
s = t = RSTRING(str)->ptr;
if (!s || RSTRING(str)->len == 0) return Qnil;
send = s + RSTRING(str)->len;
@@ -2354,6 +2354,7 @@ rb_str_squeeze_bang(argc, argv, str)
int init = 1;
int i;
+ rb_str_modify(str);
if (argc == 0) {
for (i=0; i<256; i++) {
squeez[i] = 1;
@@ -2369,7 +2370,6 @@ rb_str_squeeze_bang(argc, argv, str)
}
}
- rb_str_modify(str);
s = t = RSTRING(str)->ptr;
if (!s || RSTRING(str)->len == 0) return Qnil;
send = s + RSTRING(str)->len;