From 9a112b9ec28887185867fdc3e048f4f43d556f29 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 29 Aug 2008 02:20:23 +0000 Subject: * encoding.c (rb_enc_compatible): ASCII compatible string and US-ASCII regexp is compatible. [ruby-dev:36033] * string.c (rb_str_index_m): second argument is position of character. by usa. [ruby-dev:36033] * string.c (rb_str_rindex_m): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'string.c') diff --git a/string.c b/string.c index 26b57b5e3..180d869ac 100644 --- a/string.c +++ b/string.c @@ -2167,6 +2167,9 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str) } } + pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos, + rb_enc_check(str, sub), single_byte_optimizable(str)); + switch (TYPE(sub)) { case T_REGEXP: pos = rb_reg_adjust_startpos(sub, str, pos, 0); @@ -2277,6 +2280,9 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str) pos = len; } + pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos, + rb_enc_check(str, sub), single_byte_optimizable(str)); + switch (TYPE(sub)) { case T_REGEXP: /* enc = rb_get_check(str, sub); */ -- cgit