summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-11 22:15:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-11 22:15:11 +0000
commit1dcf1174ea2a803e6905a04760121fe1426035b3 (patch)
tree3f37ee14e1b8c7b5f6f9ce6e1e978bbf1d12d177 /ruby.c
parent9a5b57f61fd9ef14b1bc6c0b540c0edbb86a409a (diff)
* 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
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c10
1 files changed, 8 insertions, 2 deletions
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