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

ruby-changes:24259

From: naruse <ko1@a...>
Date: Thu, 5 Jul 2012 01:01:12 +0900 (JST)
Subject: [ruby-changes:24259] naruse:r36310 (trunk): * ruby.c (proc_options): warn only if -K and -w option is specified.

naruse	2012-07-05 01:01:01 +0900 (Thu, 05 Jul 2012)

  New Revision: 36310

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

  Log:
    * ruby.c (proc_options): warn only if -K and -w option is specified.
      see also r36274 [Feature #5206]

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c
    trunk/test/ruby/test_rubyoptions.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36309)
+++ ChangeLog	(revision 36310)
@@ -1,3 +1,8 @@
+Wed Jul  4 21:55:35 2012  NARUSE, Yui  <naruse@r...>
+
+	* ruby.c (proc_options): warn only if -K and -w option is specified.
+	  see also r36274 [Feature #5206]
+
 Wed Jul  4 21:41:44 2012  Naohisa Goto  <ngotogenome@g...>
 
 	* gc.c, atomic.h (ATOMIC_SIZE_*): moved from gc.c to atomic.h
Index: ruby.c
===================================================================
--- ruby.c	(revision 36309)
+++ ruby.c	(revision 36310)
@@ -920,7 +920,6 @@
 		    opt->src.enc.name = rb_str_new2(enc_name);
 		    if (!opt->ext.enc.name)
 			opt->ext.enc.name = opt->src.enc.name;
-		    rb_warn("-K%c is specified; it is for 1.8 compatibility and may cause odd behavior", rb_tolower(*s));
 		}
 		s++;
 	    }
@@ -1277,6 +1276,9 @@
 	    opt->intern.enc.name = int_enc_name;
     }
 
+    if (opt->src.enc.name)
+	rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
+
     if (opt->dump & DUMP_BIT(version)) {
 	ruby_show_version();
 	return Qtrue;
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 36309)
+++ test/ruby/test_rubyoptions.rb	(revision 36310)
@@ -121,9 +121,17 @@
     assert_in_out_err(%w(-KU), "p '\u3042'") do |r, e|
       assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
     end
-    assert_in_out_err(%w(-KE -e) + [""], "", [], /-Ke/)
-    assert_in_out_err(%w(-KS -e) + [""], "", [], /-Ks/)
-    assert_in_out_err(%w(-KN -e) + [""], "", [], /-Kn/)
+    line = '-eputs"\xc2\xa1".encoding'
+    env = {'RUBYOPT' => nil}
+    assert_in_out_err([env, '-Ke', line], "", ["EUC-JP"], [])
+    assert_in_out_err([env, '-KE', line], "", ["EUC-JP"], [])
+    assert_in_out_err([env, '-Ks', line], "", ["Windows-31J"], [])
+    assert_in_out_err([env, '-KS', line], "", ["Windows-31J"], [])
+    assert_in_out_err([env, '-Ku', line], "", ["UTF-8"], [])
+    assert_in_out_err([env, '-KU', line], "", ["UTF-8"], [])
+    assert_in_out_err([env, '-Kn', line], "", ["ASCII-8BIT"], [])
+    assert_in_out_err([env, '-KN', line], "", ["ASCII-8BIT"], [])
+    assert_in_out_err([env, '-wKe', line], "", ["EUC-JP"], /-K/)
   end
 
   def test_version
@@ -235,7 +243,7 @@
     ENV['RUBYOPT'] = '-Eus-ascii -KN'
     assert_in_out_err(%w(-Eutf-8 -KU), "p '\u3042'") do |r, e|
       assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
-      assert_match(/-Ku/, e.join)
+      assert_equal([], e)
     end
 
   ensure
@@ -287,9 +295,9 @@
     assert_in_out_err([], "#! /test_r_u_b_y_test_r_u_b_y_options_foobarbazqux -foo -bar\r\np 1\r\n",
                       [], /: no Ruby script found in input/)
 
-    assert_in_out_err([], "#!ruby -KU -Eutf-8\r\np \"\u3042\"\r\n") do |r, e|
+    assert_in_out_err([{'RUBYOPT' => nil}], "#!ruby -KU -Eutf-8\r\np \"\u3042\"\r\n") do |r, e|
       assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
-      assert_match(/-Ku/, e.join)
+      assert_equal([], e)
     end
 
     bug4118 = '[ruby-dev:42680]'

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

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