summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-23 13:16:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-23 13:16:11 +0000
commit3a2aca5075ca60dc6863bc15f07bf8e716cd556c (patch)
tree02c24c1db888eb048c885a8399b40d4ceeaa1374
parente6fe59e96e98d450c815970a3afe96278104b848 (diff)
encdb.c, utf_16_32.h: Unicode with BOM
* enc/encdb.c, enc/utf_16_32.h (ENC_DUMMY_UNICODE): Unicode with BOM must be based on big endian variants, so that actual encodings would work. [ruby-core:57318] [Bug #8940] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--enc/encdb.c2
-rw-r--r--enc/utf_16_32.h2
-rw-r--r--test/ruby/test_transcode.rb7
4 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 52fd761..a489c8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Sep 23 22:16:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * enc/encdb.c, enc/utf_16_32.h (ENC_DUMMY_UNICODE): Unicode with BOM
+ must be based on big endian variants, so that actual encodings would
+ work. [ruby-core:57318] [Bug #8940]
+
Mon Sep 23 12:11:26 2013 Masaki Matsushita <glass.saga@gmail.com>
* hash.c (env_each_pair): do not call rb_assoc_new() if
diff --git a/enc/encdb.c b/enc/encdb.c
index 32def53..106fa85 100644
--- a/enc/encdb.c
+++ b/enc/encdb.c
@@ -20,7 +20,7 @@ void rb_encdb_set_unicode(int index);
#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_DUMMY(name))
+#define ENC_DUMMY_UNICODE(name) rb_encdb_set_unicode(ENC_REPLICATE((name), name "BE"))
void
Init_encdb(void)
diff --git a/enc/utf_16_32.h b/enc/utf_16_32.h
index b232767..da58d1b 100644
--- a/enc/utf_16_32.h
+++ b/enc/utf_16_32.h
@@ -1,5 +1,5 @@
#include "regenc.h"
/* dummy for unsupported, statefull encoding */
-#define ENC_DUMMY_UNICODE(name) ENC_DUMMY(name)
+#define ENC_DUMMY_UNICODE(name) ENC_REPLICATE(name, name "BE")
ENC_DUMMY_UNICODE("UTF-16");
ENC_DUMMY_UNICODE("UTF-32");
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb
index 530e8f4..e88979a 100644
--- a/test/ruby/test_transcode.rb
+++ b/test/ruby/test_transcode.rb
@@ -2063,4 +2063,11 @@ class TestTranscode < Test::Unit::TestCase
end
assert_equal("U+3042", "\u{3042}".encode("US-ASCII", fallback: fallback.method(:escape)))
end
+
+ bug8940 = '[ruby-core:57318] [Bug #8940]'
+ %w[UTF-32 UTF-16].each do |enc|
+ define_method("test_pseudo_encoding_inspect(#{enc})") do
+ assert_normal_exit("'aaa'.encode('#{enc}').inspect", bug8940)
+ end
+ end
end