parse.y: token info with BOM

* parse.y (parser_prepare): set token_info_enabled flag first,
  before returning at BOM.  [ruby-dev:50288] [Bug #13998]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-10-11 05:34:24 +00:00
parent 3bd4910cad
commit 72c96011ea
2 changed files with 12 additions and 1 deletions

View File

@ -7148,6 +7148,7 @@ static void
parser_prepare(struct parser_params *parser)
{
int c = nextc();
parser->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
switch (c) {
case '#':
if (peek('!')) parser->has_shebang = 1;
@ -7167,7 +7168,6 @@ parser_prepare(struct parser_params *parser)
}
pushback(c);
parser->enc = rb_enc_get(lex_lastline);
parser->token_info_enabled = !compile_for_eval && RTEST(ruby_verbose);
}
#ifndef RIPPER

View File

@ -450,6 +450,17 @@ class TestRubyOptions < Test::Unit::TestCase
t.flush
assert_in_out_err(["-w", t.path], "", [], [], '[ruby-core:25442]')
end
a.for("BOM with #{b}") do
err = ["#{t.path}:2: warning: mismatched indentations at '#{e}' with '#{k}' at 1"]
t.rewind
t.truncate(0)
t.print "\u{feff}"
t.puts src
t.flush
assert_in_out_err(["-w", t.path], "", [], err)
assert_in_out_err(["-wr", t.path, "-e", ""], "", [], err)
end
end
end
end