diff --git a/ChangeLog b/ChangeLog index 7e7b38d847..ea63eb8798 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Dec 5 11:27:08 2010 Nobuyoshi Nakada + + * ruby.c (load_file_internal): decrement for ungotten line. + [ruby-dev:42680] + Sun Dec 5 10:32:11 2010 Tanaka Akira * complex.c: parenthesize macro arguments. diff --git a/ruby.c b/ruby.c index ecce05afe4..d09c32e99c 100644 --- a/ruby.c +++ b/ruby.c @@ -1551,6 +1551,7 @@ load_file_internal(VALUE arg) rb_funcall(f, set_encoding, 1, rb_enc_from_encoding(enc)); if (xflag || opt->xflag) { + line_start--; search_shebang: forbid_setid("-x"); opt->xflag = FALSE; diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index e47060f354..9fad50ae4c 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -271,6 +271,12 @@ class TestRubyOptions < Test::Unit::TestCase assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8)) assert_equal([], e) end + + bug4118 = '[ruby-dev:42680]' + assert_in_out_err(%w[], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n", + %w[4], [], bug4118) + assert_in_out_err(%w[-x], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n", + %w[4], [], bug4118) end def test_sflag