[前][次][番号順一覧][スレッド一覧]

ruby-changes:9271

From: yugui <ko1@a...>
Date: Wed, 17 Dec 2008 15:15:06 +0900 (JST)
Subject: [ruby-changes:9271] Ruby:r20808 (ruby_1_9_1): merges r20741 from trunk into ruby_1_9_1.

yugui	2008-12-17 15:14:51 +0900 (Wed, 17 Dec 2008)

  New Revision: 20808

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20808

  Log:
    merges r20741 from trunk into ruby_1_9_1.
    * 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:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/ruby.c

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 20807)
+++ ruby_1_9_1/ChangeLog	(revision 20808)
@@ -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.
+
 Sun Dec 14 14:26:11 2008  Yuki Sonoda (Yugui)  <yugui@y...>
 
 	* spec/README: directory structrue changed
Index: ruby_1_9_1/ruby.c
===================================================================
--- ruby_1_9_1/ruby.c	(revision 20807)
+++ ruby_1_9_1/ruby.c	(revision 20808)
@@ -210,9 +210,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);
@@ -226,8 +226,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
@@ -298,11 +298,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
@@ -394,7 +400,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
@@ -1141,18 +1147,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->yydebug) rb_parser_set_yydebug(parser, Qtrue);
     if (opt->ext.enc.name != 0) {
@@ -1177,6 +1182,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);
 
@@ -1240,6 +1254,7 @@
     }
 
     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/

[前][次][番号順一覧][スレッド一覧]