ruby-changes:9119
From: yugui <ko1@a...>
Date: Fri, 12 Dec 2008 14:25:53 +0900 (JST)
Subject: [ruby-changes:9119] Ruby:r20656 (trunk): * encoding.c (enc_get_default_encoding): removed.
yugui 2008-12-12 14:25:39 +0900 (Fri, 12 Dec 2008) New Revision: 20656 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20656 Log: * encoding.c (enc_get_default_encoding): removed. Generalizing rb_default_{external,internal}_encoding seems to be difficult. default_external cannot be NULL even before detected. [ruby-dev:37390] * encoding.c (rb_default_external_encoding): has its own implementation again. * encoding.c (rb_default_internal_encoding): ditto. * gem_prelude.rb: added notice. * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): uses locale encoding but not ASCII-8BIT. * ruby.c (process_options): refers less to default_external. Modified files: trunk/ChangeLog trunk/encoding.c trunk/gem_prelude.rb trunk/ruby.c Index: encoding.c =================================================================== --- encoding.c (revision 20655) +++ encoding.c (revision 20656) @@ -1037,15 +1037,6 @@ rb_encoding *enc; }; -static rb_encoding * -enc_get_default_encoding(struct default_encoding *def) -{ - if (!def->enc && def->index >= 0) { - def->enc = rb_enc_from_index(def->index); - } - return def->enc; -} - static int enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const char *name, int defindex) @@ -1077,7 +1068,15 @@ rb_encoding * rb_default_external_encoding(void) { - return enc_get_default_encoding(&default_external); + if (default_external.enc) return default_external.enc; + + if (default_external.index >= 0) { + default_external.enc = rb_enc_from_index(default_external.index); + return default_external.enc; + } + else { + return rb_locale_encoding(); + } } VALUE @@ -1126,7 +1125,10 @@ rb_encoding * rb_default_internal_encoding(void) { - return enc_get_default_encoding(&default_internal); + if (!default_internal.enc && default_internal.index >= 0) { + default_internal.enc = rb_enc_from_index(default_internal.index); + } + return default_internal.enc; /* can be NULL */ } VALUE Index: ChangeLog =================================================================== --- ChangeLog (revision 20655) +++ ChangeLog (revision 20656) @@ -1,3 +1,22 @@ +Fri Dec 12 14:09:55 2008 Yuki Sonoda (Yugui) <yugui@y...> + + * encoding.c (enc_get_default_encoding): removed. + Generalizing rb_default_{external,internal}_encoding seems to be + difficult. + default_external cannot be NULL even before detected. [ruby-dev:37390] + + * encoding.c (rb_default_external_encoding): has its own + implementation again. + + * encoding.c (rb_default_internal_encoding): ditto. + + * gem_prelude.rb: added notice. + + * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): uses locale + encoding but not ASCII-8BIT. + + * ruby.c (process_options): refers less to default_external. + Fri Dec 12 11:00:52 2008 Nobuyoshi Nakada <nobu@r...> * load.c (rb_feature_p): load path must be expanded. Index: gem_prelude.rb =================================================================== --- gem_prelude.rb (revision 20655) +++ gem_prelude.rb (revision 20656) @@ -2,6 +2,10 @@ # vim: filetype=ruby # THIS FILE WAS AUTOGENERATED, DO NOT EDIT +# NOTICE: Ruby is during initialization here. +# * Encoding.default_external does not reflects -E. +# * Should not expect Encoding.default_internal. +# * Locale encoding is available. if defined?(Gem) then module Kernel Index: ruby.c =================================================================== --- ruby.c (revision 20655) +++ ruby.c (revision 20656) @@ -213,9 +213,9 @@ } } if (!newp || l < oldl || STRNCASECMP(oldp, s, oldl) != 0) { - return rb_str_new(s, l); + return rb_locale_str_new(s, l); } - ret = rb_str_new(0, l + newl - oldl); + ret = rb_locale_str_new(0, l + newl - oldl); ptr = RSTRING_PTR(ret); memcpy(ptr, newp, newl); memcpy(ptr + newl, s + oldl, l - oldl); @@ -229,8 +229,8 @@ return rubylib_mangled_path(s, strlen(s)); } #else -#define rubylib_mangled_path rb_str_new -#define rubylib_mangled_path2 rb_str_new2 +#define rubylib_mangled_path rb_locale_str_new +#define rubylib_mangled_path2 rb_locale_str_new_cstr #endif static void @@ -1178,7 +1178,7 @@ } } - ruby_script(opt->script); + rb_progname = rb_obj_freeze(rb_str_new_cstr(opt->script)); #if defined DOSISH || defined __CYGWIN__ translate_char(RSTRING_PTR(rb_progname), '\\', '/'); #endif @@ -1670,7 +1670,7 @@ struct cmdline_options opt; NODE *tree; - ruby_script(argv[0]); /* for the time being */ + ruby_script(argv[0]); /* for the time being */ rb_argv0 = rb_str_new4(rb_progname); rb_gc_register_mark_object(rb_argv0); args.argc = argc; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/