summaryrefslogtreecommitdiff
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
parent5ee029f62cbb728453f6db3ae54127a376696447 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--string.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 031d4740ec..a300c4ba2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Dec 10 16:52:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_insert): should not add length in bytes to index in
+ chars.
+
Mon Dec 10 14:33:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_f_public_send): rename invoke_method to public_send.
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);