diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-29 12:23:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-29 12:23:04 +0000 |
commit | 290deeb7052f54b2bf7adb520c0601b578524580 (patch) | |
tree | bd6601cf3d21ddd91ae900f627ae09fa7a653126 | |
parent | 3d458cd051c29e7644812fb13db7c3c6812edae8 (diff) |
ruby.c: overriding warning options
* ruby.c (proc_options): successive -W option overrides previous
warning options.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ruby.c | 6 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 1 |
2 files changed, 5 insertions, 2 deletions
@@ -832,6 +832,7 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt) { long n, argc0 = argc; const char *s; + int warning = opt->warning; if (argc == 0) return 0; @@ -881,7 +882,7 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt) opt->verbose = 1; case 'w': if (!opt->warning) { - opt->warning = 1; + warning = 1; ruby_verbose = Qtrue; } s++; @@ -911,7 +912,7 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt) break; } } - opt->warning = 1; + warning = 1; } goto reswitch; @@ -1234,6 +1235,7 @@ proc_options(long argc, char **argv, struct cmdline_options *opt, int envopt) } switch_end: + if (warning) opt->warning = warning; return argc0 - argc; } diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 95d60d9933..ba74be5eac 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -64,6 +64,7 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(%w(-W1 -e) + ['p $-W'], "", %w(1), []) assert_in_out_err(%w(-Wx -e) + ['p $-W'], "", %w(1), []) assert_in_out_err(%w(-W -e) + ['p $-W'], "", %w(2), []) + assert_in_out_err(%w(-w -W0 -e) + ['p $-W'], "", %w(0), []) ensure ENV['RUBYOPT'] = save_rubyopt end |