From b1d5d1666ea6486b3631080d394505451845cfee Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 10 Dec 2024 15:48:18 -0600 Subject: [PATCH] [ruby/resolv] Check for Windows in JRuby-compatible way https://github.com/ruby/resolv/commit/de95f557b0 --- lib/resolv.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/resolv.rb b/lib/resolv.rb index e46b4cef92..2ec1d6c6f9 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -173,11 +173,14 @@ class Resolv class ResolvTimeout < Timeout::Error; end + WINDOWS = /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/ + private_constant :WINDOWS + ## # Resolv::Hosts is a hostname resolver that uses the system hosts file. class Hosts - if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM and + if WINDOWS begin require 'win32/resolv' DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL @@ -1019,7 +1022,7 @@ class Resolv if File.exist? filename config_hash = Config.parse_resolv_conf(filename) else - if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM + if WINDOWS require 'win32/resolv' search, nameserver = Win32::Resolv.get_resolv_info config_hash = {}