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

ruby-changes:7397

From: naruse <ko1@a...>
Date: Fri, 29 Aug 2008 11:20:44 +0900 (JST)
Subject: [ruby-changes:7397] Ruby:r18916 (trunk): * encoding.c (rb_enc_compatible): ASCII compatible string and US-ASCII

naruse	2008-08-29 11:20:23 +0900 (Fri, 29 Aug 2008)

  New Revision: 18916

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

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/encoding.c
    trunk/string.c

Index: encoding.c
===================================================================
--- encoding.c	(revision 18915)
+++ encoding.c	(revision 18916)
@@ -631,6 +631,10 @@
     if (!rb_enc_asciicompat(enc1) || !rb_enc_asciicompat(enc2)) {
 	return 0;
     }
+    if (BUILTIN_TYPE(str2) == T_REGEXP && idx2 == ENCINDEX_US_ASCII)
+	return enc1;
+    if (BUILTIN_TYPE(str1) == T_REGEXP && idx1 == ENCINDEX_US_ASCII)
+	return enc2;
 
     if (BUILTIN_TYPE(str1) != T_STRING) {
 	VALUE tmp = str1;
@@ -652,7 +656,7 @@
 		if (cr2 == ENC_CODERANGE_7BIT) return enc1;
 	    }
 	    if (cr2 == ENC_CODERANGE_7BIT) {
-		if (idx1 == 0) return enc2;
+		if (idx1 == ENCINDEX_ASCII) return enc2;
 		return enc1;
 	    }
 	}
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18915)
+++ ChangeLog	(revision 18916)
@@ -1,3 +1,13 @@
+Fri Aug 29 11:04:03 2008  NARUSE, Yui  <naruse@r...>
+
+	* 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.
+
 Fri Aug 29 04:47:49 2008  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (rb_w32_read, rb_w32_write): more accurate handling
Index: string.c
===================================================================
--- string.c	(revision 18915)
+++ string.c	(revision 18916)
@@ -2167,6 +2167,9 @@
 	}
     }
 
+    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 @@
 	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); */

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

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