* 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:
naruse 2010-09-24 06:28:35 +00:00
Родитель aa836e539f
Коммит 955507313b
2 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}