[前][次][番号順一覧][スレッド一覧]

ruby-changes:7400

From: naruse <ko1@a...>
Date: Fri, 29 Aug 2008 18:23:25 +0900 (JST)
Subject: [ruby-changes:7400] Ruby:r18919 (trunk): * string.c (rb_str_index_m): only regexp uses byte offset.

naruse	2008-08-29 18:22:17 +0900 (Fri, 29 Aug 2008)

  New Revision: 18919

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18919

  Log:
    * string.c (rb_str_index_m): only regexp uses byte offset.
    
    * string.c (rb_str_rindex_m): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18918)
+++ ChangeLog	(revision 18919)
@@ -1,3 +1,9 @@
+Fri Aug 29 18:20:56 2008  NARUSE, Yui  <naruse@r...>
+
+	* 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@a...>
 
 	* vm_insnhelper.c (vm_call_method): copy arguments to allocated
Index: string.c
===================================================================
--- string.c	(revision 18918)
+++ string.c	(revision 18919)
@@ -2167,11 +2167,11 @@
 	}
     }
 
-    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 @@
 	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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]