ruby-changes:15021
From: nobu <ko1@a...>
Date: Sat, 13 Mar 2010 00:11:31 +0900 (JST)
Subject: [ruby-changes:15021] Ruby:r26895 (trunk): * ruby.c (ruby_init_loadpath_safe): mark initial load paths.
nobu 2010-03-13 00:11:10 +0900 (Sat, 13 Mar 2010) New Revision: 26895 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26895 Log: * ruby.c (ruby_init_loadpath_safe): mark initial load paths. * gem_prelude.rb (push_all_highest_version_gems_on_load_path): search insertion position by initial load path mark. * lib/rubygems.rb (Gem.load_path_insert_index): ditto. Modified files: trunk/ChangeLog trunk/gem_prelude.rb trunk/lib/rubygems.rb trunk/ruby.c trunk/tool/compile_prelude.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26894) +++ ChangeLog (revision 26895) @@ -1,3 +1,12 @@ +Sat Mar 13 00:11:05 2010 Nobuyoshi Nakada <nobu@r...> + + * ruby.c (ruby_init_loadpath_safe): mark initial load paths. + + * gem_prelude.rb (push_all_highest_version_gems_on_load_path): + search insertion position by initial load path mark. + + * lib/rubygems.rb (Gem.load_path_insert_index): ditto. + Fri Mar 12 21:34:00 2010 Kenta Murata <mrkn@m...> * NEWS: emoji encodings. Index: gem_prelude.rb =================================================================== --- gem_prelude.rb (revision 26894) +++ gem_prelude.rb (revision 26895) @@ -267,7 +267,7 @@ require_paths.first.instance_variable_set(:@gem_prelude_index, true) end # gem directories must come after -I and ENV['RUBYLIB'] - $:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths + $:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = require_paths end def const_missing(constant) Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 26894) +++ lib/rubygems.rb (revision 26895) @@ -254,8 +254,6 @@ File.join spec.full_gem_path, path end - sitelibdir = ConfigMap[:sitelibdir] - # gem directories must come after -I and ENV['RUBYLIB'] insert_index = load_path_insert_index @@ -570,23 +568,9 @@ ## # The index to insert activated gem paths into the $LOAD_PATH. - # - # Defaults to the site lib directory unless gem_prelude.rb has loaded paths, - # then it inserts the activated gem's paths before the gem_prelude.rb paths - # so you can override the gem_prelude.rb default $LOAD_PATH paths. def self.load_path_insert_index - index = $LOAD_PATH.index ConfigMap[:sitelibdir] - - $LOAD_PATH.each_with_index do |path, i| - if path.instance_variables.include?(:@gem_prelude_index) or - path.instance_variables.include?('@gem_prelude_index') then - index = i - break - end - end - - index + $LOAD_PATH.index {|path| path.instance_variable_defined?(:@gem_prelude_index)} end ## Index: ruby.c =================================================================== --- ruby.c (revision 26894) +++ ruby.c (revision 26895) @@ -339,6 +339,7 @@ ruby_init_loadpath_safe(int safe_level) { VALUE load_path; + ID id_initial_load_path_mark; extern const char ruby_initial_load_paths[]; const char *paths = ruby_initial_load_paths; #if defined LOAD_RELATIVE @@ -432,16 +433,18 @@ #define RUBY_RELATIVE(path, len) rubylib_mangled_path(path, len) #define PREFIX_PATH() rubylib_mangled_path(RUBY_LIB_PREFIX, sizeof(RUBY_LIB_PREFIX)-1) #endif -#define incpush(path) rb_ary_push(load_path, (path)) load_path = GET_VM()->load_path; if (safe_level == 0) { ruby_push_include(getenv("RUBYLIB"), identical_path); } + id_initial_load_path_mark = rb_intern_const("@gem_prelude_index"); while (*paths) { size_t len = strlen(paths); - incpush(RUBY_RELATIVE(paths, len)); + VALUE path = RUBY_RELATIVE(paths, len); + rb_ivar_set(path, id_initial_load_path_mark, path); + rb_ary_push(load_path, path); paths += len + 1; } Index: tool/compile_prelude.rb =================================================================== --- tool/compile_prelude.rb (revision 26894) +++ tool/compile_prelude.rb (revision 26895) @@ -48,7 +48,7 @@ key = $1 unless @mkconf require './rbconfig' - @mkconf = RbConfig::MAKEFILE_CONFIG.merge('rubylibprefix'=>'#{TMP_RUBY_PREFIX}') + @mkconf = RbConfig::MAKEFILE_CONFIG.merge('prefix'=>'#{TMP_RUBY_PREFIX}') end if RbConfig::MAKEFILE_CONFIG.has_key? key val = RbConfig.expand("$(#{key})", @mkconf) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/