summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-24 08:15:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-24 08:15:18 +0000
commitd8441fcc6edec94921a827980035091db875979d (patch)
tree5cfdf39a5a9683fab41dc4fc80504e46d9d0edcf
parent84a5622646dd12550e57b16e46f272ab7d49a766 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--enc/encdb.c4
-rw-r--r--encoding.c18
-rw-r--r--test/-ext-/string/test_ellipsize.rb1
-rwxr-xr-xtest/csv/test_encodings.rb1
5 files changed, 25 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 34f2c6f..7d60bdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Sep 24 17:15:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* ext/win32/lib/win32/registry.rb (Win32::Registry#write): data size
diff --git a/enc/encdb.c b/enc/encdb.c
index 106fa85..fa04a5f 100644
--- a/enc/encdb.c
+++ b/enc/encdb.c
@@ -14,13 +14,15 @@ int rb_encdb_alias(const char *alias, const char *orig);
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)
diff --git a/encoding.c b/encoding.c
index 3b9b790..8f2e65a 100644
--- a/encoding.c
+++ b/encoding.c
@@ -24,6 +24,7 @@
#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 char *orig)
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)
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));
diff --git a/test/-ext-/string/test_ellipsize.rb b/test/-ext-/string/test_ellipsize.rb
index 2d066d0..6ef7d0a 100644
--- a/test/-ext-/string/test_ellipsize.rb
+++ b/test/-ext-/string/test_ellipsize.rb
@@ -34,7 +34,6 @@ class Test_StringEllipsize < Test::Unit::TestCase
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)
diff --git a/test/csv/test_encodings.rb b/test/csv/test_encodings.rb
index 872914e..85ed21a 100755
--- a/test/csv/test_encodings.rb
+++ b/test/csv/test_encodings.rb
@@ -326,7 +326,6 @@ class TestCSV::Encodings < TestCSV
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