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

ruby-changes:66802

From: aycabta <ko1@a...>
Date: Fri, 16 Jul 2021 01:55:40 +0900 (JST)
Subject: [ruby-changes:66802] f1035248af (master): [ruby/irb] Show code page by irb_info on Windows

https://git.ruby-lang.org/ruby.git/commit/?id=f1035248af

From f1035248af04b2a4d58990740c3f1b840a5eac78 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Thu, 15 Jul 2021 23:42:11 +0900
Subject: [ruby/irb] Show code page by irb_info on Windows

https://github.com/ruby/irb/commit/6160d74199
---
 lib/irb/cmd/info.rb  | 4 ++++
 test/irb/test_cmd.rb | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb
index a23d502..2f3fef1 100644
--- a/lib/irb/cmd/info.rb
+++ b/lib/irb/cmd/info.rb
@@ -16,6 +16,10 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/cmd/info.rb#L16
             str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
             str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
             str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
+            if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
+              codepage = `chcp`.sub(/Active code page: (\d+)\n/, '\1')
+              str += "Code page: #{codepage}\n"
+            end
             str
           end
           alias_method :to_s, :inspect
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb
index adf671f..e6bb587 100644
--- a/test/irb/test_cmd.rb
+++ b/test/irb/test_cmd.rb
@@ -47,6 +47,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L47
       @default_encoding = [Encoding.default_external, Encoding.default_internal]
       @stdio_encodings = [STDIN, STDOUT, STDERR].map {|io| [io.external_encoding, io.internal_encoding] }
       IRB.instance_variable_get(:@CONF).clear
+      @is_win = (RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/)
     end
 
     def teardown
@@ -80,6 +81,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L81
         InputMethod:\sAbstract\sInputMethod\n
         \.irbrc\spath:\s.+\n
         RUBY_PLATFORM:\s.+\n
+        #{@is_win ? 'Code\spage:\s\d+\n' : ''}
       }x
       assert_match expected, irb.context.main.irb_info.to_s
     ensure
@@ -105,6 +107,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L107
         InputMethod:\sAbstract\sInputMethod\n
         \.irbrc\spath:\s.+\n
         RUBY_PLATFORM:\s.+\n
+        #{@is_win ? 'Code\spage:\s\d+\n' : ''}
       }x
       assert_match expected, irb.context.main.irb_info.to_s
     ensure
@@ -132,6 +135,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L135
         IRB\sversion:\sirb\s.+\n
         InputMethod:\sAbstract\sInputMethod\n
         RUBY_PLATFORM:\s.+\n
+        #{@is_win ? 'Code\spage:\s\d+\n' : ''}
         \z
       }x
       assert_match expected, irb.context.main.irb_info.to_s
@@ -163,6 +167,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L167
         IRB\sversion:\sirb\s.+\n
         InputMethod:\sAbstract\sInputMethod\n
         RUBY_PLATFORM:\s.+\n
+        #{@is_win ? 'Code\spage:\s\d+\n' : ''}
         \z
       }x
       assert_match expected, irb.context.main.irb_info.to_s
-- 
cgit v1.1


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

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