From 04e68d0107460575a86cc427338eae436be16286 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 12 Mar 2010 15:11:10 +0000 Subject: * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ gem_prelude.rb | 2 +- lib/rubygems.rb | 18 +----------------- ruby.c | 7 +++++-- tool/compile_prelude.rb | 2 +- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93dba151fe..b78f7d2c05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sat Mar 13 00:11:05 2010 Nobuyoshi Nakada + + * 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 * NEWS: emoji encodings. diff --git a/gem_prelude.rb b/gem_prelude.rb index fac6a3806a..5928356afa 100644 --- a/gem_prelude.rb +++ b/gem_prelude.rb @@ -267,7 +267,7 @@ if defined?(Gem) then 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) diff --git a/lib/rubygems.rb b/lib/rubygems.rb index dd086bc821..d0c82970eb 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -254,8 +254,6 @@ module Gem 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 @@ module Gem ## # 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 ## diff --git a/ruby.c b/ruby.c index fdca44593d..bf0f83d67c 100644 --- a/ruby.c +++ b/ruby.c @@ -339,6 +339,7 @@ void 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 @@ ruby_init_loadpath_safe(int safe_level) #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; } diff --git a/tool/compile_prelude.rb b/tool/compile_prelude.rb index d13670d955..93a6dd9cf0 100755 --- a/tool/compile_prelude.rb +++ b/tool/compile_prelude.rb @@ -48,7 +48,7 @@ class Prelude 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) -- cgit v1.2.3