mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_rindex): use rb_enc_prev_char instead of repeated str_nth.
patched by Michael Selig [ruby-core:32498] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aa836e539f
commit
955507313b
2 changed files with 8 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-09-24 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_rindex): use rb_enc_prev_char instead of repeated str_nth.
|
||||
patched by Michael Selig [ruby-core:32498]
|
||||
|
||||
Fri Sep 24 14:19:12 2010 URABE Shyouhei <shyouhei@ruby-lang.org>
|
||||
|
||||
* test/test_pty.rb: Same as 229281; existence of PTY class do not
|
||||
|
|
6
string.c
6
string.c
|
@ -2488,14 +2488,14 @@ rb_str_rindex(VALUE str, VALUE sub, long pos)
|
|||
e = RSTRING_END(str);
|
||||
t = RSTRING_PTR(sub);
|
||||
slen = RSTRING_LEN(sub);
|
||||
for (;;) {
|
||||
s = str_nth(sbeg, e, pos, enc, singlebyte);
|
||||
if (!s) return -1;
|
||||
s = str_nth(sbeg, e, pos, enc, singlebyte);
|
||||
while (s) {
|
||||
if (memcmp(s, t, slen) == 0) {
|
||||
return pos;
|
||||
}
|
||||
if (pos == 0) break;
|
||||
pos--;
|
||||
s = rb_enc_prev_char(sbeg, s, e, enc);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue