diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-25 19:11:51 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-25 19:11:51 +0000 |
| commit | 5c54c57521234cb4d5cbac816d43653dbb6c3169 (patch) | |
| tree | bcf47cc8f2924c88c3ed10534225766c54056067 /ruby.c | |
| parent | 908667e45a9cbbb954530f3c46e7a73a261d5a7d (diff) | |
* prelude.rb, Makefile.in, common.mk: Introduce prelude.rb.
* eval.c (rb_eval_prelude): New function exported only for use in
preludes.
* configure.in: Define RUBY_EXEC_PREFIX and RUBY_LIB_PREFIX.
* ruby.c (proc_options, ruby_init_loadpath, ruby_prelude): Load
prelude.
* compile_prelude.rb: Port the prelude compiler from trunk.
* miniprelude.c: Currently miniruby does not include prelude.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
| -rw-r--r-- | ruby.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -254,6 +254,7 @@ ruby_init_loadpath() { #if defined LOAD_RELATIVE char libpath[FILENAME_MAX+1]; + size_t baselen; char *p; int rest; #if defined _WIN32 || defined __CYGWIN__ @@ -298,12 +299,16 @@ ruby_init_loadpath() strcpy(libpath, "."); p = libpath + 1; } +#define PREFIX_PATH() rb_str_new(libpath, baselen) - rest = FILENAME_MAX - (p - libpath); + baselen = p - libpath; + rest = FILENAME_MAX - baselen; #define RUBY_RELATIVE(path) (strncpy(p, (path), rest), libpath) #else + static const char exec_prefix[] = RUBY_EXEC_PREFIX; #define RUBY_RELATIVE(path) (path) +#define PREFIX_PATH() rubylib_mangled_path(exec_prefix, sizeof(exec_prefix)-1) #endif #define incpush(path) rb_ary_push(rb_load_path, rubylib_mangled_path2(path)) @@ -338,6 +343,8 @@ ruby_init_loadpath() if (rb_safe_level() == 0) { incpush("."); } + + rb_const_set(rb_cObject, rb_intern("TMP_RUBY_PREFIX"), rb_obj_freeze(PREFIX_PATH())); } struct req_list { @@ -481,6 +488,16 @@ moreswitches(s) return s; } +static void ruby_prelude _((void)); +void Init_prelude _((void)); + +static void +ruby_prelude() +{ + Init_prelude(); + rb_const_remove(rb_cObject, rb_intern("TMP_RUBY_PREFIX")); +} + static void proc_options(argc, argv) int argc; @@ -841,6 +858,7 @@ proc_options(argc, argv) process_sflag(); ruby_init_loadpath(); + ruby_prelude(); ruby_sourcefile = rb_source_filename(argv0); if (e_script) { require_libraries(); |
