From 290deeb7052f54b2bf7adb520c0601b578524580 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Dec 2015 12:23:04 +0000 Subject: 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 --- ruby.c | 6 ++++-- test/ruby/test_rubyoptions.rb | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ruby.c b/ruby.c index 2e586c4..0a39bfb 100644 --- a/ruby.c +++ b/ruby.c @@ -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 95d60d9..ba74be5 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 -- cgit v1.1