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

ruby-changes:30955

From: nobu <ko1@a...>
Date: Tue, 24 Sep 2013 17:15:25 +0900 (JST)
Subject: [ruby-changes:30955] nobu:r43034 (trunk): encdb.c, encoding.c: make BOM-encodings dummy

nobu	2013-09-24 17:15:18 +0900 (Tue, 24 Sep 2013)

  New Revision: 43034

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

  Log:
    encdb.c, encoding.c: make BOM-encodings dummy
    
    * enc/encdb.c (ENC_DUMMY_UNICODE): make BOM-encodings dummy.
    * encoding.c (enc_autoload): keep dummy encodings dummy.

  Modified files:
    trunk/ChangeLog
    trunk/enc/encdb.c
    trunk/encoding.c
    trunk/test/-ext-/string/test_ellipsize.rb
    trunk/test/csv/test_encodings.rb
Index: encoding.c
===================================================================
--- encoding.c	(revision 43033)
+++ encoding.c	(revision 43034)
@@ -24,6 +24,7 @@ https://github.com/ruby/ruby/blob/trunk/encoding.c#L24
 #pragma GCC visibility push(default)
 int rb_enc_register(const char *name, rb_encoding *encoding);
 void rb_enc_set_base(const char *name, const char *orig);
+int rb_enc_set_dummy(int index);
 void rb_encdb_declare(const char *name);
 int rb_encdb_replicate(const char *name, const char *orig);
 int rb_encdb_dummy(const char *name);
@@ -362,6 +363,18 @@ rb_enc_set_base(const char *name, const https://github.com/ruby/ruby/blob/trunk/encoding.c#L363
     set_base_encoding(idx, rb_enc_from_index(origidx));
 }
 
+/* for encdb.h
+ * Set encoding dummy.
+ */
+int
+rb_enc_set_dummy(int index)
+{
+    rb_encoding *enc = enc_table.list[index].enc;
+
+    ENC_SET_DUMMY(enc);
+    return index;
+}
+
 int
 rb_enc_replicate(const char *name, rb_encoding *encoding)
 {
@@ -647,8 +660,9 @@ enc_autoload(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/encoding.c#L660
 	if (enc_autoload_p(base)) {
 	    if (enc_autoload(base) < 0) return -1;
 	}
-	i = ENC_TO_ENCINDEX(enc);
-	enc_register_at(i, rb_enc_name(enc), base);
+	i = enc->ruby_encoding_index;
+	enc_register_at(i & ENC_INDEX_MASK, rb_enc_name(enc), base);
+	enc->ruby_encoding_index = i;
     }
     else {
 	i = load_encoding(rb_enc_name(enc));
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43033)
+++ ChangeLog	(revision 43034)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Sep 24 17:15:10 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* enc/encdb.c (ENC_DUMMY_UNICODE): make BOM-encodings dummy.
+
+	* encoding.c (enc_autoload): keep dummy encodings dummy.
+
 Tue Sep 24 16:41:15 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/win32/lib/win32/registry.rb (Win32::Registry#write): data size
Index: enc/encdb.c
===================================================================
--- enc/encdb.c	(revision 43033)
+++ enc/encdb.c	(revision 43034)
@@ -14,13 +14,15 @@ int rb_encdb_alias(const char *alias, co https://github.com/ruby/ruby/blob/trunk/enc/encdb.c#L14
 int rb_encdb_dummy(const char *name);
 void rb_encdb_declare(const char *name);
 void rb_enc_set_base(const char *name, const char *orig);
+int rb_enc_set_dummy(int index);
 void rb_encdb_set_unicode(int index);
 #define ENC_REPLICATE(name, orig) rb_encdb_replicate((name), (orig))
 #define ENC_ALIAS(name, orig) rb_encdb_alias((name), (orig))
 #define ENC_DUMMY(name) rb_encdb_dummy(name)
 #define ENC_DEFINE(name) rb_encdb_declare(name)
 #define ENC_SET_BASE(name, orig) rb_enc_set_base((name), (orig))
-#define ENC_DUMMY_UNICODE(name) rb_encdb_set_unicode(ENC_REPLICATE((name), name "BE"))
+#define ENC_SET_DUMMY(name, orig) rb_enc_set_dummy(name)
+#define ENC_DUMMY_UNICODE(name) rb_encdb_set_unicode(rb_enc_set_dummy(ENC_REPLICATE((name), name "BE")))
 
 void
 Init_encdb(void)
Index: test/-ext-/string/test_ellipsize.rb
===================================================================
--- test/-ext-/string/test_ellipsize.rb	(revision 43033)
+++ test/-ext-/string/test_ellipsize.rb	(revision 43034)
@@ -34,7 +34,6 @@ class Test_StringEllipsize < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_ellipsize.rb#L34
     a = "\u3042"
     encs = Encoding.list.each do |enc|
       next if enc.dummy?
-      next if enc == Encoding::UTF_16 or enc == Encoding::UTF_32
       begin
         s = a.encode(enc)
         e = "...".encode(enc)
Index: test/csv/test_encodings.rb
===================================================================
--- test/csv/test_encodings.rb	(revision 43033)
+++ test/csv/test_encodings.rb	(revision 43034)
@@ -326,7 +326,6 @@ class TestCSV::Encodings < TestCSV https://github.com/ruby/ruby/blob/trunk/test/csv/test_encodings.rb#L326
   def each_encoding
     Encoding.list.each do |encoding|
       next if encoding.dummy?  # skip "dummy" encodings
-      next if encoding == Encoding::UTF_32 or encoding == Encoding::UTF_16
       yield encoding
     end
   end

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

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