summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-24 13:18:54 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-24 13:18:54 +0000
commited77aff154497bd7fc9941277842481a8d0d00d4 (patch)
tree999d7d6aac1085292f45590bc0363435689063ad /string.c
parentf001a450f2263a74cc38e650361da161305d776f (diff)
* string.c (rb_str_rpartition): revert r39903, and convert byte offset
to char offset; the return value of rb_reg_search is byte offset, but other than it of rb_str_rpartition expects char offset. [Bug #8138] [ruby-dev:47183] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39906 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 271afa75f0..dad27cfb7a 100644
--- a/string.c
+++ b/string.c
@@ -7522,6 +7522,7 @@ rb_str_rpartition(VALUE str, VALUE sep)
if (RB_TYPE_P(sep, T_REGEXP)) {
pos = rb_reg_search(sep, str, pos, 1);
+ pos = rb_str_sublen(str, pos);
regex = TRUE;
}
else {
@@ -7542,10 +7543,9 @@ rb_str_rpartition(VALUE str, VALUE sep)
if (regex) {
sep = rb_reg_nth_match(0, rb_backref_get());
}
- return rb_ary_new3(3, rb_str_subseq(str, 0, pos),
+ return rb_ary_new3(3, rb_str_substr(str, 0, pos),
sep,
- rb_str_subseq(str, pos+RSTRING_LEN(sep),
- RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
+ rb_str_substr(str,pos+str_strlen(sep,STR_ENC_GET(sep)),RSTRING_LEN(str)));
}
/*