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

ruby-changes:31089

From: nobu <ko1@a...>
Date: Mon, 7 Oct 2013 15:50:23 +0900 (JST)
Subject: [ruby-changes:31089] nobu:r43168 (trunk): win32/file.c: use encoding index

nobu	2013-10-07 15:50:18 +0900 (Mon, 07 Oct 2013)

  New Revision: 43168

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

  Log:
    win32/file.c: use encoding index
    
    * win32/file.c (code_page): use encoding index, which is primary
      entity, instead of encoding name.

  Modified files:
    trunk/win32/file.c
Index: win32/file.c
===================================================================
--- win32/file.c	(revision 43167)
+++ win32/file.c	(revision 43168)
@@ -176,7 +176,8 @@ system_code_page(void) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L176
 static UINT
 code_page(rb_encoding *enc)
 {
-    st_data_t enc_name, code_page_value;
+    int enc_idx;
+    st_data_t code_page_value;
     VALUE encoding, names_ary = Qundef, name;
     ID names;
     long i;
@@ -184,19 +185,19 @@ code_page(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L185
     if (!enc)
 	return system_code_page();
 
+    enc_idx = rb_enc_to_index(enc);
+
     /* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */
-    if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) {
+    if (enc_idx == rb_usascii_encindex() || enc_idx == rb_ascii8bit_encindex()) {
 	return 1252;
     }
 
-    enc_name = (st_data_t)rb_enc_name(enc);
-
     if (rb_code_page) {
-	if (st_lookup(rb_code_page, enc_name, &code_page_value))
+	if (st_lookup(rb_code_page, enc_idx, &code_page_value))
 	    return (UINT)code_page_value;
     }
     else {
-	rb_code_page = st_init_strcasetable();
+	rb_code_page = st_init_numtable();
     }
 
     code_page_value = INVALID_CODE_PAGE;
@@ -216,7 +217,7 @@ code_page(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L217
 	}
     }
 
-    st_insert(rb_code_page, enc_name, code_page_value);
+    st_insert(rb_code_page, enc_idx, code_page_value);
     return (UINT)code_page_value;
 }
 

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

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