From a7db2c1efdbf8fc96d06f4b5692d93941ccec606 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 18 Nov 2009 03:38:20 +0000 Subject: * 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 --- encoding.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'encoding.c') diff --git a/encoding.c b/encoding.c index 9d956337ee..bd73880944 100644 --- a/encoding.c +++ b/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) { -- cgit v1.2.3