summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ruby.c4
-rw-r--r--test/ruby/test_rubyoptions.rb7
-rw-r--r--vm.c10
4 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e7ddf84d4..35fc0238b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jun 5 09:56:57 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ruby.c (process_options): revert r25330, so that $0 can be seen
+ from required libraries by -r option. [ruby-core:23717]
+
Sat Jun 5 08:30:42 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_f_test): 'W' should test writable by real uid/git,
diff --git a/ruby.c b/ruby.c
index 0e87a146c7..82857c87ba 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1356,6 +1356,8 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
}
}
ruby_init_gems(!(opt->disable & DISABLE_BIT(gems)));
+ rb_progname = opt->script_name;
+ rb_vm_set_progname(rb_progname);
ruby_set_argv(argc, argv);
process_sflag(&opt->sflag);
@@ -1400,8 +1402,6 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
tree = load_file(parser, opt->script, 1, opt);
});
}
- rb_progname = opt->script_name;
- rb_vm_set_progname(rb_progname);
if (opt->dump & DUMP_BIT(yydebug)) return Qtrue;
if (opt->ext.enc.index >= 0) {
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 7b956810a1..dcdfd85fea 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -319,10 +319,11 @@ class TestRubyOptions < Test::Unit::TestCase
def test_notfound
notexist = "./notexist.rb"
rubybin = Regexp.quote(EnvUtil.rubybin)
- pat = /\A#{rubybin}:.* -- #{Regexp.quote(notexist)} \(LoadError\)\Z/
+ pat = Regexp.quote(notexist)
+ bug1573 = '[ruby-core:23717]'
assert_equal(false, File.exist?(notexist))
- assert_in_out_err(["-r", notexist, "-ep"], "", [], pat)
- assert_in_out_err([notexist], "", [], pat)
+ assert_in_out_err(["-r", notexist, "-ep"], "", [], /\A-e:.* -- #{pat} \(LoadError\)\Z/, bug1573)
+ assert_in_out_err([notexist], "", [], /\A#{pat}:.* -- #{pat} \(LoadError\)\Z/, bug1573)
end
def test_program_name
diff --git a/vm.c b/vm.c
index 1817e6e797..04d1c815c3 100644
--- a/vm.c
+++ b/vm.c
@@ -761,8 +761,14 @@ vm_backtrace_push(void *arg, VALUE file, int line_no, VALUE name)
VALUE *aryp = arg;
VALUE bt;
- bt = rb_enc_sprintf(rb_enc_compatible(file, name), "%s:%d:in `%s'",
- RSTRING_PTR(file), line_no, RSTRING_PTR(name));
+ if (line_no) {
+ bt = rb_enc_sprintf(rb_enc_compatible(file, name), "%s:%d:in `%s'",
+ RSTRING_PTR(file), line_no, RSTRING_PTR(name));
+ }
+ else {
+ bt = rb_enc_sprintf(rb_enc_compatible(file, name), "%s:in `%s'",
+ RSTRING_PTR(file), RSTRING_PTR(name));
+ }
rb_ary_push(*aryp, bt);
return 0;
}