summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-29 09:22:17 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-29 09:22:17 +0000
commitb253f3561794b8bbcedeeee3eec37565172e2cc4 (patch)
tree3adae7effe090235496fdd147a367a38c6f00d30
parentc74b31a4504f13d985752503e5f9f05ce51d7bef (diff)
downloadruby-b253f3561794b8bbcedeeee3eec37565172e2cc4.tar.gz
ruby-b253f3561794b8bbcedeeee3eec37565172e2cc4.tar.xz
ruby-b253f3561794b8bbcedeeee3eec37565172e2cc4.zip
* string.c (rb_str_index_m): only regexp uses byte offset.
* string.c (rb_str_rindex_m): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--string.c12
2 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 9134621c7..ca67590b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Aug 29 18:20:56 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * string.c (rb_str_index_m): only regexp uses byte offset.
+
+ * string.c (rb_str_rindex_m): ditto.
+
Fri Aug 29 16:48:34 2008 Koichi Sasada <ko1@atdot.net>
* vm_insnhelper.c (vm_call_method): copy arguments to allocated
diff --git a/string.c b/string.c
index 180d869ac..f835f5e7d 100644
--- a/string.c
+++ b/string.c
@@ -2167,11 +2167,11 @@ 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 = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
+ rb_enc_check(str, sub), single_byte_optimizable(str));
+
pos = rb_reg_adjust_startpos(sub, str, pos, 0);
pos = rb_reg_search(sub, str, pos, 0);
pos = rb_str_sublen(str, pos);
@@ -2280,12 +2280,12 @@ 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); */
+ pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
+ rb_enc_check(str, sub), single_byte_optimizable(str));
+
if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
pos = rb_reg_adjust_startpos(sub, str, pos, 1);
pos = rb_reg_search(sub, str, pos, 1);