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

ruby-changes:33570

From: naruse <ko1@a...>
Date: Mon, 21 Apr 2014 19:15:59 +0900 (JST)
Subject: [ruby-changes:33570] naruse:r45651 (trunk): * string.c (rb_str_coderange_scan_restartable): coderange is always

naruse	2014-04-21 19:15:54 +0900 (Mon, 21 Apr 2014)

  New Revision: 45651

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

  Log:
    * string.c (rb_str_coderange_scan_restartable): coderange is always
      ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non
      ASCII character.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45650)
+++ ChangeLog	(revision 45651)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Apr 21 19:12:20 2014  NARUSE, Yui  <naruse@r...>
+
+	* string.c (rb_str_coderange_scan_restartable): coderange is always
+	  ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non
+	  ASCII character.
+
 Mon Apr 21 19:02:44 2014  NARUSE, Yui  <naruse@r...>
 
 	* string.c (coderange_scan): remove useless condtion `p < e` after
Index: string.c
===================================================================
--- string.c	(revision 45650)
+++ string.c	(revision 45651)
@@ -304,7 +304,7 @@ coderange_scan(const char *p, long len, https://github.com/ruby/ruby/blob/trunk/string.c#L304
 {
     const char *e = p + len;
 
-    if (rb_enc_to_index(enc) == 0) {
+    if (rb_enc_to_index(enc) == rb_ascii8bit_encindex()) {
         /* enc is ASCII-8BIT.  ASCII-8BIT string never be broken. */
         p = search_nonascii(p, e);
         return p ? ENC_CODERANGE_VALID : ENC_CODERANGE_7BIT;
@@ -340,10 +340,11 @@ rb_str_coderange_scan_restartable(const https://github.com/ruby/ruby/blob/trunk/string.c#L340
     if (*cr == ENC_CODERANGE_BROKEN)
 	return e - s;
 
-    if (rb_enc_to_index(enc) == 0) {
+    if (rb_enc_to_index(enc) == rb_ascii8bit_encindex()) {
 	/* enc is ASCII-8BIT.  ASCII-8BIT string never be broken. */
+	if (*cr == ENC_CODERANGE_VALID) return e - s;
 	p = search_nonascii(p, e);
-	*cr = (!p && *cr != ENC_CODERANGE_VALID) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
+        *cr = p ? ENC_CODERANGE_VALID : ENC_CODERANGE_7BIT;
 	return e - s;
     }
     else if (rb_enc_asciicompat(enc)) {

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

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