mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* encoding.c (enc_set_default_encoding): reset filesytem
encoding because on resetting default_external because Unix's filesystem encoding depends on default_external. * encoding.c (enc_set_filesystem_encoding): added. * ruby.c (process_options): don't call rb_filesystem_encoding because filesystem encoding is reset when default_external is reset. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a1c4d60560
commit
a7db2c1efd
4 changed files with 37 additions and 5 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Wed Nov 18 12:33:42 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* encoding.c (enc_set_default_encoding): reset filesytem
|
||||
encoding because on resetting default_external because
|
||||
Unix's filesystem encoding depends on default_external.
|
||||
|
||||
* encoding.c (enc_set_filesystem_encoding): added.
|
||||
|
||||
* ruby.c (process_options): don't call rb_filesystem_encoding
|
||||
because filesystem encoding is reset when default_external
|
||||
is reset.
|
||||
|
||||
Wed Nov 18 11:57:32 2009 TAKANO Mitsuhiro (takano32) <tak@no32.tk>
|
||||
|
||||
* math.c (math_gamma): fix incorrect comparison expression.
|
||||
|
|
19
encoding.c
19
encoding.c
|
@ -1116,7 +1116,7 @@ rb_locale_encoding(void)
|
|||
}
|
||||
|
||||
static int
|
||||
rb_filesystem_encindex(void)
|
||||
enc_set_filesystem_encoding(void)
|
||||
{
|
||||
int idx;
|
||||
#if defined NO_LOCALE_CHARMAP
|
||||
|
@ -1132,8 +1132,16 @@ rb_filesystem_encindex(void)
|
|||
idx = rb_enc_to_index(rb_default_external_encoding());
|
||||
#endif
|
||||
|
||||
if (rb_enc_registered("filesystem") < 0) enc_alias_internal("filesystem", idx);
|
||||
enc_alias_internal("filesystem", idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
static int
|
||||
rb_filesystem_encindex(void)
|
||||
{
|
||||
int idx = rb_enc_registered("filesystem");
|
||||
if (idx < 0)
|
||||
idx = enc_set_filesystem_encoding();
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
@ -1148,6 +1156,8 @@ struct default_encoding {
|
|||
rb_encoding *enc;
|
||||
};
|
||||
|
||||
static struct default_encoding default_external = {0};
|
||||
|
||||
static int
|
||||
enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const char *name)
|
||||
{
|
||||
|
@ -1169,11 +1179,12 @@ enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const cha
|
|||
enc_alias_internal(name, def->index);
|
||||
}
|
||||
|
||||
if (def == &default_external)
|
||||
enc_set_filesystem_encoding();
|
||||
|
||||
return overridden;
|
||||
}
|
||||
|
||||
static struct default_encoding default_external = {0};
|
||||
|
||||
rb_encoding *
|
||||
rb_default_external_encoding(void)
|
||||
{
|
||||
|
|
1
ruby.c
1
ruby.c
|
@ -1324,7 +1324,6 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
|
|||
enc = lenc;
|
||||
}
|
||||
rb_enc_set_default_external(rb_enc_from_encoding(enc));
|
||||
(void)rb_filesystem_encoding();
|
||||
if (opt->intern.enc.index >= 0) {
|
||||
enc = rb_enc_from_index(opt->intern.enc.index);
|
||||
rb_enc_set_default_internal(rb_enc_from_encoding(enc));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'test/unit'
|
||||
require_relative 'envutil'
|
||||
|
||||
class TestEncoding < Test::Unit::TestCase
|
||||
|
||||
|
@ -39,6 +40,15 @@ class TestEncoding < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { Encoding.find("foobarbazqux") }
|
||||
assert_nothing_raised{Encoding.find("locale")}
|
||||
assert_nothing_raised{Encoding.find("filesystem")}
|
||||
|
||||
if /(?:ms|dar)win/ !~ RUBY_PLATFORM
|
||||
# Unix's filesystem encoding is default_external
|
||||
assert_ruby_status(%w[-EUTF-8:EUC-JP], <<-'EOS')
|
||||
exit Encoding.find("filesystem") == Encoding::UTF_8
|
||||
Encoding.default_external = Encoding::EUC_JP
|
||||
exit Encoding.find("filesystem") == Encoding::EUC_JP
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def test_dummy_p
|
||||
|
|
Loading…
Reference in a new issue