mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
84a5622646
commit
d8441fcc6e
5 changed files with 25 additions and 5 deletions
|
@ -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>
|
Tue Sep 24 16:41:15 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/win32/lib/win32/registry.rb (Win32::Registry#write): data size
|
* ext/win32/lib/win32/registry.rb (Win32::Registry#write): data size
|
||||||
|
|
|
@ -14,13 +14,15 @@ int rb_encdb_alias(const char *alias, const char *orig);
|
||||||
int rb_encdb_dummy(const char *name);
|
int rb_encdb_dummy(const char *name);
|
||||||
void rb_encdb_declare(const char *name);
|
void rb_encdb_declare(const char *name);
|
||||||
void rb_enc_set_base(const char *name, const char *orig);
|
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);
|
void rb_encdb_set_unicode(int index);
|
||||||
#define ENC_REPLICATE(name, orig) rb_encdb_replicate((name), (orig))
|
#define ENC_REPLICATE(name, orig) rb_encdb_replicate((name), (orig))
|
||||||
#define ENC_ALIAS(name, orig) rb_encdb_alias((name), (orig))
|
#define ENC_ALIAS(name, orig) rb_encdb_alias((name), (orig))
|
||||||
#define ENC_DUMMY(name) rb_encdb_dummy(name)
|
#define ENC_DUMMY(name) rb_encdb_dummy(name)
|
||||||
#define ENC_DEFINE(name) rb_encdb_declare(name)
|
#define ENC_DEFINE(name) rb_encdb_declare(name)
|
||||||
#define ENC_SET_BASE(name, orig) rb_enc_set_base((name), (orig))
|
#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
|
void
|
||||||
Init_encdb(void)
|
Init_encdb(void)
|
||||||
|
|
18
encoding.c
18
encoding.c
|
@ -24,6 +24,7 @@
|
||||||
#pragma GCC visibility push(default)
|
#pragma GCC visibility push(default)
|
||||||
int rb_enc_register(const char *name, rb_encoding *encoding);
|
int rb_enc_register(const char *name, rb_encoding *encoding);
|
||||||
void rb_enc_set_base(const char *name, const char *orig);
|
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);
|
void rb_encdb_declare(const char *name);
|
||||||
int rb_encdb_replicate(const char *name, const char *orig);
|
int rb_encdb_replicate(const char *name, const char *orig);
|
||||||
int rb_encdb_dummy(const char *name);
|
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));
|
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
|
int
|
||||||
rb_enc_replicate(const char *name, rb_encoding *encoding)
|
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_p(base)) {
|
||||||
if (enc_autoload(base) < 0) return -1;
|
if (enc_autoload(base) < 0) return -1;
|
||||||
}
|
}
|
||||||
i = ENC_TO_ENCINDEX(enc);
|
i = enc->ruby_encoding_index;
|
||||||
enc_register_at(i, rb_enc_name(enc), base);
|
enc_register_at(i & ENC_INDEX_MASK, rb_enc_name(enc), base);
|
||||||
|
enc->ruby_encoding_index = i;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
i = load_encoding(rb_enc_name(enc));
|
i = load_encoding(rb_enc_name(enc));
|
||||||
|
|
|
@ -34,7 +34,6 @@ class Test_StringEllipsize < Test::Unit::TestCase
|
||||||
a = "\u3042"
|
a = "\u3042"
|
||||||
encs = Encoding.list.each do |enc|
|
encs = Encoding.list.each do |enc|
|
||||||
next if enc.dummy?
|
next if enc.dummy?
|
||||||
next if enc == Encoding::UTF_16 or enc == Encoding::UTF_32
|
|
||||||
begin
|
begin
|
||||||
s = a.encode(enc)
|
s = a.encode(enc)
|
||||||
e = "...".encode(enc)
|
e = "...".encode(enc)
|
||||||
|
|
|
@ -326,7 +326,6 @@ class TestCSV::Encodings < TestCSV
|
||||||
def each_encoding
|
def each_encoding
|
||||||
Encoding.list.each do |encoding|
|
Encoding.list.each do |encoding|
|
||||||
next if encoding.dummy? # skip "dummy" encodings
|
next if encoding.dummy? # skip "dummy" encodings
|
||||||
next if encoding == Encoding::UTF_32 or encoding == Encoding::UTF_16
|
|
||||||
yield encoding
|
yield encoding
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue