mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3d458cd051
commit
290deeb705
2 changed files with 5 additions and 2 deletions
6
ruby.c
6
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue