summaryrefslogtreecommitdiffstats
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
commit0b826dda97acd2b542c28811266864abefa69fa1 (patch)
tree3b8a93af505813415df06a7aa811bfcba1ca46e5 /string.c
parent12e012ed5d9ea6be4e9729cd3fbd05081f71afea (diff)
downloadruby-0b826dda97acd2b542c28811266864abefa69fa1.tar.gz
ruby-0b826dda97acd2b542c28811266864abefa69fa1.tar.xz
ruby-0b826dda97acd2b542c28811266864abefa69fa1.zip
* string.c (rb_str_insert): should not add length in bytes to index in
chars. git-svn-id: http://svn.ruby-lang.org/repos/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 9ed5dfa05..9eba3b884 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);