From 1dcf1174ea2a803e6905a04760121fe1426035b3 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 11 Mar 2010 22:15:11 +0000 Subject: * ruby.c (ruby_init_loadpath_safe, ruby_init_gems): set and remove TMP_RUBY_PREFIX. * variable.c (rb_mod_remove_const): new function. * tool/compile_prelude.rb: split each preludes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 536772032b..fdca44593d 100644 --- a/ruby.c +++ b/ruby.c @@ -358,7 +358,7 @@ ruby_init_loadpath_safe(int safe_level) #if defined _WIN32 || defined __CYGWIN__ # if VARIABLE_LIBPATH - sopath = rb_str_tmp_new(MAXPATHLEN); + sopath = rb_str_new(0, MAXPATHLEN); libpath = RSTRING_PTR(sopath); GetModuleFileName(libruby, libpath, MAXPATHLEN); # else @@ -390,7 +390,7 @@ ruby_init_loadpath_safe(int safe_level) const int win_to_posix = CCP_WIN_A_TO_POSIX | CCP_RELATIVE; size_t newsize = cygwin_conv_path(win_to_posix, libpath, 0, 0); if (newsize > 0) { - VALUE rubylib = rb_str_tmp_new(newsize); + VALUE rubylib = rb_str_new(0, newsize); p = RSTRING_PTR(rubylib); if (cygwin_conv_path(win_to_posix, libpath, p, newsize) == 0) { rb_str_resize(sopath, 0); @@ -418,8 +418,10 @@ ruby_init_loadpath_safe(int safe_level) strlcpy(libpath, ".", sizeof(libpath)); p = libpath + 1; } +#define PREFIX_PATH() rb_str_new(libpath, baselen) #else rb_str_set_len(sopath, p - libpath); +#define PREFIX_PATH() sopath #endif baselen = p - libpath; @@ -428,6 +430,7 @@ ruby_init_loadpath_safe(int safe_level) #define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), path, len) #else #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; @@ -441,6 +444,8 @@ ruby_init_loadpath_safe(int safe_level) incpush(RUBY_RELATIVE(paths, len)); paths += len + 1; } + + rb_const_set(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"), rb_obj_freeze(PREFIX_PATH())); } @@ -1086,6 +1091,7 @@ ruby_init_gems(int enable) { if (enable) rb_define_module("Gem"); Init_prelude(); + rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX")); } static int -- cgit v1.2.3