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

ruby-changes:31086

From: nobu <ko1@a...>
Date: Mon, 7 Oct 2013 15:09:11 +0900 (JST)
Subject: [ruby-changes:31086] nobu:r43165 (trunk): win32/file.c: check ASCII encodings first

nobu	2013-10-07 15:09:01 +0900 (Mon, 07 Oct 2013)

  New Revision: 43165

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

  Log:
    win32/file.c: check ASCII encodings first
    
    * win32/file.c (code_page): check US-ASCII and ASCII-8bit before
      ordinary mapping.

  Modified files:
    trunk/win32/file.c
Index: win32/file.c
===================================================================
--- win32/file.c	(revision 43164)
+++ win32/file.c	(revision 43165)
@@ -186,6 +186,11 @@ code_page(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L186
     if (!enc)
 	return system_code_page();
 
+    /* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */
+    if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) {
+	return 1252;
+    }
+
     enc_name = (char *)rb_enc_name(enc);
 
     fake_str.basic.flags = T_STRING|RSTRING_NOEMBED;
@@ -206,16 +211,6 @@ code_page(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L211
     if (!NIL_P(encoding)) {
 	CONST_ID(names, "names");
 	names_ary = rb_funcall(encoding, names, 0);
-    }
-
-    /* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */
-    if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) {
-	UINT code_page = 1252;
-	rb_hash_aset(rb_code_page, name_key, INT2FIX(code_page));
-	return code_page;
-    }
-
-    if (names_ary != Qundef) {
 	for (i = 0; i < RARRAY_LEN(names_ary); i++) {
 	    name = RARRAY_PTR(names_ary)[i];
 	    if (strncmp("CP", RSTRING_PTR(name), 2) == 0) {

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

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