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

ruby-changes:41297

From: nobu <ko1@a...>
Date: Tue, 29 Dec 2015 19:12:59 +0900 (JST)
Subject: [ruby-changes:41297] nobu:r53369 (trunk): ruby.c: command line option over RUBYOPT env

nobu	2015-12-29 19:12:48 +0900 (Tue, 29 Dec 2015)

  New Revision: 53369

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

  Log:
    ruby.c: command line option over RUBYOPT env
    
    * ruby.c (proc_options): -W command line option should be able to
      override -w in RUBYOPT environment variable.

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c
    trunk/test/ruby/test_rubyoptions.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53368)
+++ ChangeLog	(revision 53369)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 29 19:12:46 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (proc_options): -W command line option should be able to
+	  override -w in RUBYOPT environment variable.
+
 Tue Dec 29 17:54:16 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* eval.c (ignored_block): warn if a block is given to `using`,
Index: ruby.c
===================================================================
--- ruby.c	(revision 53368)
+++ ruby.c	(revision 53369)
@@ -110,6 +110,7 @@ struct cmdline_options { https://github.com/ruby/ruby/blob/trunk/ruby.c#L110
 	} enc;
     } src, ext, intern;
     VALUE req_list;
+    unsigned int warning: 1;
 };
 
 static void init_ids(struct cmdline_options *);
@@ -879,15 +880,19 @@ proc_options(long argc, char **argv, str https://github.com/ruby/ruby/blob/trunk/ruby.c#L880
 	    opt->dump |= DUMP_BIT(version_v);
 	    opt->verbose = 1;
 	  case 'w':
-	    ruby_verbose = Qtrue;
+	    if (!opt->warning) {
+		opt->warning = 1;
+		ruby_verbose = Qtrue;
+	    }
 	    s++;
 	    goto reswitch;
 
 	  case 'W':
-	    {
+	    if (!opt->warning) {
 		size_t numlen;
 		int v = 2;	/* -W as -W2 */
 
+		opt->warning = 1;
 		if (*++s) {
 		    v = scan_oct(s, 1, &numlen);
 		    if (numlen == 0)
@@ -1705,6 +1710,7 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1710
 		if (RSTRING_PTR(line)[RSTRING_LEN(line) - 2] == '\r')
 		    RSTRING_PTR(line)[RSTRING_LEN(line) - 2] = '\0';
 		if ((p = strstr(p, " -")) != 0) {
+		    opt->warning = 0;
 		    moreswitches(p + 1, opt, 0);
 		}
 
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 53368)
+++ test/ruby/test_rubyoptions.rb	(revision 53369)
@@ -258,6 +258,10 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L258
       assert_equal([], e)
     end
 
+    ENV['RUBYOPT'] = '-w'
+    assert_in_out_err(%w(), "p $VERBOSE", ["true"])
+    assert_in_out_err(%w(-W1), "p $VERBOSE", ["false"])
+    assert_in_out_err(%w(-W0), "p $VERBOSE", ["nil"])
   ensure
     if rubyopt_orig
       ENV['RUBYOPT'] = rubyopt_orig

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

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