ruby-changes:9204
From: nobu <ko1@a...>
Date: Mon, 15 Dec 2008 11:34:55 +0900 (JST)
Subject: [ruby-changes:9204] Ruby:r20741 (trunk): * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): cannot use
nobu 2008-12-15 11:32:21 +0900 (Mon, 15 Dec 2008) New Revision: 20741 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20741 Log: * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): cannot use locale encoding before load path is initialized * ruby.c (ruby_init_loadpath_safe): ditto. * ruby.c (process_options): loads encdb so that encodings can be loaded, then associates script name and load paths with the locale encoding. Modified files: trunk/ChangeLog trunk/ruby.c Index: ChangeLog =================================================================== --- ChangeLog (revision 20740) +++ ChangeLog (revision 20741) @@ -1,3 +1,14 @@ +Mon Dec 15 11:32:18 2008 Nobuyoshi Nakada <nobu@r...> + + * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): cannot use + locale encoding before load path is initialized + + * ruby.c (ruby_init_loadpath_safe): ditto. + + * ruby.c (process_options): loads encdb so that encodings can be + loaded, then associates script name and load paths with the + locale encoding. + Mon Dec 15 10:00:36 2008 Nobuyoshi Nakada <nobu@r...> * common.mk (btest-ruby): use RUNRUBY instead of MINIRUBY to load the Index: ruby.c =================================================================== --- ruby.c (revision 20740) +++ ruby.c (revision 20741) @@ -213,9 +213,9 @@ } } if (!newp || l < oldl || STRNCASECMP(oldp, s, oldl) != 0) { - return rb_locale_str_new(s, l); + return rb_str_new(s, l); } - ret = rb_locale_str_new(0, l + newl - oldl); + ret = rb_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_locale_str_new -#define rubylib_mangled_path2 rb_locale_str_new_cstr +#define rubylib_mangled_path rb_str_new +#define rubylib_mangled_path2 rb_str_new_cstr #endif static void @@ -301,11 +301,17 @@ { return path; } +static VALUE +locale_path(VALUE path) +{ + rb_enc_associate(path, rb_locale_encoding()); + return path; +} void ruby_incpush(const char *path) { - ruby_push_include(path, identical_path); + ruby_push_include(path, locale_path); } static VALUE @@ -397,7 +403,7 @@ load_path = GET_VM()->load_path; if (safe_level == 0) { - ruby_incpush(getenv("RUBYLIB")); + ruby_push_include(getenv("RUBYLIB"), identical_path); } #ifdef RUBY_SEARCH_PATH @@ -1178,18 +1184,17 @@ } } - rb_progname = rb_obj_freeze(rb_str_new_cstr(opt->script)); + opt->script_name = rb_str_new_cstr(opt->script); + opt->script = RSTRING_PTR(opt->script_name); #if defined DOSISH || defined __CYGWIN__ - translate_char(RSTRING_PTR(rb_progname), '\\', '/'); + translate_char(opt->script, '\\', '/'); #endif - opt->script_name = rb_progname; - opt->script = RSTRING_PTR(opt->script_name); + rb_obj_freeze(opt->script_name); ruby_init_loadpath_safe(opt->safe_level); - ruby_init_gems(!(opt->disable & DISABLE_BIT(gems))); + rb_enc_find_index("encdb"); lenc = rb_locale_encoding(); rb_enc_associate(rb_progname, lenc); - opt->script_name = rb_str_new4(rb_progname); parser = rb_parser_new(); if (opt->dump & DUMP_BIT(yydebug)) { rb_parser_set_yydebug(parser, Qtrue); @@ -1216,6 +1221,15 @@ rb_enc_set_default_internal(rb_enc_from_encoding(enc)); opt->intern.enc.index = -1; } + rb_enc_associate(opt->script_name, lenc); + { + long i; + VALUE load_path = GET_VM()->load_path; + for (i = 0; i < RARRAY_LEN(load_path); ++i) { + rb_enc_associate(RARRAY_PTR(load_path)[i], lenc); + } + } + ruby_init_gems(!(opt->disable & DISABLE_BIT(gems))); ruby_set_argv(argc, argv); process_sflag(opt); @@ -1284,6 +1298,7 @@ rb_define_readonly_boolean("$-a", opt->do_split); rb_set_safe_level(opt->safe_level); + rb_progname = opt->script_name; return iseq; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/