mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ruby.c (proc_options): warn only if -K and -w option is specified.
see also r36274 [Feature #5206] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87c25d897b
commit
007c9aa2bf
3 changed files with 22 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Jul 4 21:55:35 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* ruby.c (proc_options): warn only if -K and -w option is specified.
|
||||
see also r36274 [Feature #5206]
|
||||
|
||||
Wed Jul 4 21:41:44 2012 Naohisa Goto <ngotogenome@gmail.com>
|
||||
|
||||
* gc.c, atomic.h (ATOMIC_SIZE_*): moved from gc.c to atomic.h
|
||||
|
|
4
ruby.c
4
ruby.c
|
@ -920,7 +920,6 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt)
|
|||
opt->src.enc.name = rb_str_new2(enc_name);
|
||||
if (!opt->ext.enc.name)
|
||||
opt->ext.enc.name = opt->src.enc.name;
|
||||
rb_warn("-K%c is specified; it is for 1.8 compatibility and may cause odd behavior", rb_tolower(*s));
|
||||
}
|
||||
s++;
|
||||
}
|
||||
|
@ -1277,6 +1276,9 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
|
|||
opt->intern.enc.name = int_enc_name;
|
||||
}
|
||||
|
||||
if (opt->src.enc.name)
|
||||
rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
|
||||
|
||||
if (opt->dump & DUMP_BIT(version)) {
|
||||
ruby_show_version();
|
||||
return Qtrue;
|
||||
|
|
|
@ -121,9 +121,17 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
assert_in_out_err(%w(-KU), "p '\u3042'") do |r, e|
|
||||
assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
|
||||
end
|
||||
assert_in_out_err(%w(-KE -e) + [""], "", [], /-Ke/)
|
||||
assert_in_out_err(%w(-KS -e) + [""], "", [], /-Ks/)
|
||||
assert_in_out_err(%w(-KN -e) + [""], "", [], /-Kn/)
|
||||
line = '-eputs"\xc2\xa1".encoding'
|
||||
env = {'RUBYOPT' => nil}
|
||||
assert_in_out_err([env, '-Ke', line], "", ["EUC-JP"], [])
|
||||
assert_in_out_err([env, '-KE', line], "", ["EUC-JP"], [])
|
||||
assert_in_out_err([env, '-Ks', line], "", ["Windows-31J"], [])
|
||||
assert_in_out_err([env, '-KS', line], "", ["Windows-31J"], [])
|
||||
assert_in_out_err([env, '-Ku', line], "", ["UTF-8"], [])
|
||||
assert_in_out_err([env, '-KU', line], "", ["UTF-8"], [])
|
||||
assert_in_out_err([env, '-Kn', line], "", ["ASCII-8BIT"], [])
|
||||
assert_in_out_err([env, '-KN', line], "", ["ASCII-8BIT"], [])
|
||||
assert_in_out_err([env, '-wKe', line], "", ["EUC-JP"], /-K/)
|
||||
end
|
||||
|
||||
def test_version
|
||||
|
@ -235,7 +243,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
ENV['RUBYOPT'] = '-Eus-ascii -KN'
|
||||
assert_in_out_err(%w(-Eutf-8 -KU), "p '\u3042'") do |r, e|
|
||||
assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
|
||||
assert_match(/-Ku/, e.join)
|
||||
assert_equal([], e)
|
||||
end
|
||||
|
||||
ensure
|
||||
|
@ -287,9 +295,9 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
assert_in_out_err([], "#! /test_r_u_b_y_test_r_u_b_y_options_foobarbazqux -foo -bar\r\np 1\r\n",
|
||||
[], /: no Ruby script found in input/)
|
||||
|
||||
assert_in_out_err([], "#!ruby -KU -Eutf-8\r\np \"\u3042\"\r\n") do |r, e|
|
||||
assert_in_out_err([{'RUBYOPT' => nil}], "#!ruby -KU -Eutf-8\r\np \"\u3042\"\r\n") do |r, e|
|
||||
assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
|
||||
assert_match(/-Ku/, e.join)
|
||||
assert_equal([], e)
|
||||
end
|
||||
|
||||
bug4118 = '[ruby-dev:42680]'
|
||||
|
|
Loading…
Add table
Reference in a new issue