aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-10 07:52:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-10 07:52:19 +0000
commitc26e32ec168040c5778dfdd6a435d53ab283a181 (patch)
tree3b8a93af505813415df06a7aa811bfcba1ca46e5 /string.c
parent5ee029f62cbb728453f6db3ae54127a376696447 (diff)
downloadruby-c26e32ec168040c5778dfdd6a435d53ab283a181.tar.gz
* string.c (rb_str_insert): should not add length in bytes to index in
chars. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/string.c b/string.c
index 9ed5dfa057..9eba3b8847 100644
--- a/string.c
+++ b/string.c
@@ -2247,7 +2247,7 @@ rb_str_insert(VALUE str, VALUE idx, VALUE str2)
long pos = NUM2LONG(idx);
if (pos == -1) {
- pos = RSTRING_LEN(str);
+ return rb_str_append(str, str2);
}
else if (pos < 0) {
pos++;
@@ -2655,9 +2655,9 @@ rb_str_replace(VALUE str, VALUE str2)
STR_SET_NOEMBED(str);
RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1);
memcpy(RSTRING_PTR(str), RSTRING_PTR(str2), len+1);
- FL_SET(str, STR_ASSOC);
+ FL_SET(str, STR_ASSOC);
RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
- }
+ }
else {
rb_str_modify(str);
rb_str_resize(str, len);