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

ruby-changes:69967

From: Nobuyoshi <ko1@a...>
Date: Mon, 29 Nov 2021 23:00:47 +0900 (JST)
Subject: [ruby-changes:69967] 4acc7563a1 (master): Consider environment variable case-insensitiveness

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

From 4acc7563a111fd35524b07150990dc3ef842a685 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 28 Nov 2021 21:49:03 +0900
Subject: Consider environment variable case-insensitiveness

---
 tool/lib/leakchecker.rb | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb
index 052bea5e537..ed507969402 100644
--- a/tool/lib/leakchecker.rb
+++ b/tool/lib/leakchecker.rb
@@ -209,13 +209,28 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/tool/lib/leakchecker.rb#L209
     return leaked
   end
 
-  def find_env
-    ENV.to_h
+  e = ENV["_Ruby_Env_Ignorecase_"], ENV["_RUBY_ENV_IGNORECASE_"]
+  begin
+    ENV["_Ruby_Env_Ignorecase_"] = ENV["_RUBY_ENV_IGNORECASE_"] = nil
+    ENV["_RUBY_ENV_IGNORECASE_"] = "ENV_CASE_TEST"
+    ENV_IGNORECASE = ENV["_Ruby_Env_Ignorecase_"] == "ENV_CASE_TEST"
+  ensure
+    ENV["_Ruby_Env_Ignorecase_"], ENV["_RUBY_ENV_IGNORECASE_"] = e
+  end
+
+  if ENV_IGNORECASE
+    def find_env
+      ENV.to_h {|k, v| [k.upcase, v]}
+    end
+  else
+    def find_env
+      ENV.to_h
+    end
   end
 
   def check_env(test_name)
     old_env = @env_info
-    new_env = ENV.to_h
+    new_env = find_env
     return false if old_env == new_env
     (old_env.keys | new_env.keys).sort.each {|k|
       if old_env.has_key?(k)
-- 
cgit v1.2.1


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

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