[前][次][番号順一覧][スレッド一覧]

ruby-changes:41300

From: nobu <ko1@a...>
Date: Tue, 29 Dec 2015 21:23:08 +0900 (JST)
Subject: [ruby-changes:41300] nobu:r53372 (trunk): ruby.c: overriding warning options

nobu	2015-12-29 21:23:04 +0900 (Tue, 29 Dec 2015)

  New Revision: 53372

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53372

  Log:
    ruby.c: overriding warning options
    
    * ruby.c (proc_options): successive -W option overrides previous
      warning options.

  Modified files:
    trunk/ruby.c
    trunk/test/ruby/test_rubyoptions.rb
Index: ruby.c
===================================================================
--- ruby.c	(revision 53371)
+++ ruby.c	(revision 53372)
@@ -832,6 +832,7 @@ proc_options(long argc, char **argv, str https://github.com/ruby/ruby/blob/trunk/ruby.c#L832
 {
     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, str https://github.com/ruby/ruby/blob/trunk/ruby.c#L882
 	    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, str https://github.com/ruby/ruby/blob/trunk/ruby.c#L912
 			break;
 		    }
 		}
-		opt->warning = 1;
+		warning = 1;
 	    }
 	    goto reswitch;
 
@@ -1234,6 +1235,7 @@ proc_options(long argc, char **argv, str https://github.com/ruby/ruby/blob/trunk/ruby.c#L1235
     }
 
   switch_end:
+    if (warning) opt->warning = warning;
     return argc0 - argc;
 }
 
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 53371)
+++ test/ruby/test_rubyoptions.rb	(revision 53372)
@@ -64,6 +64,7 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L64
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]