* 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
This commit is contained in:
parent
f001a450f2
commit
ed77aff154
@ -1,3 +1,10 @@
|
|||||||
|
Sun Mar 24 22:13:51 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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]
|
||||||
|
|
||||||
Sun Mar 24 18:29:46 2013 Akinori MUSHA <knu@iDaemons.org>
|
Sun Mar 24 18:29:46 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* string.c (rb_str_rpartition): Fix String#rpartition(/re/)
|
* string.c (rb_str_rpartition): Fix String#rpartition(/re/)
|
||||||
|
1
re.c
1
re.c
@ -1348,6 +1348,7 @@ rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int reverse)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns byte offset */
|
||||||
long
|
long
|
||||||
rb_reg_search(VALUE re, VALUE str, long pos, int reverse)
|
rb_reg_search(VALUE re, VALUE str, long pos, int reverse)
|
||||||
{
|
{
|
||||||
|
6
string.c
6
string.c
@ -7522,6 +7522,7 @@ rb_str_rpartition(VALUE str, VALUE sep)
|
|||||||
|
|
||||||
if (RB_TYPE_P(sep, T_REGEXP)) {
|
if (RB_TYPE_P(sep, T_REGEXP)) {
|
||||||
pos = rb_reg_search(sep, str, pos, 1);
|
pos = rb_reg_search(sep, str, pos, 1);
|
||||||
|
pos = rb_str_sublen(str, pos);
|
||||||
regex = TRUE;
|
regex = TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -7542,10 +7543,9 @@ rb_str_rpartition(VALUE str, VALUE sep)
|
|||||||
if (regex) {
|
if (regex) {
|
||||||
sep = rb_reg_nth_match(0, rb_backref_get());
|
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,
|
sep,
|
||||||
rb_str_subseq(str, pos+RSTRING_LEN(sep),
|
rb_str_substr(str,pos+str_strlen(sep,STR_ENC_GET(sep)),RSTRING_LEN(str)));
|
||||||
RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user