summaryrefslogtreecommitdiff
path: root/ext/dl/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-31 16:55:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-31 16:55:54 +0000
commit29b538fa7146f899775b001a55bf1716c486b293 (patch)
treeeb0688cb6ea59353ba8794500bbebc4b35e29951 /ext/dl/win32
parent597179bb95812dcf90b75520d3dd17d94ac16d51 (diff)
* lib/resolv.rb (Resolv::Config.default_config_hash): requires
win32/resolv to use Win32::Resolv. [ruby-dev:34138] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/win32')
-rw-r--r--ext/dl/win32/lib/win32/registry.rb5
-rw-r--r--ext/dl/win32/lib/win32/resolv.rb12
2 files changed, 11 insertions, 6 deletions
diff --git a/ext/dl/win32/lib/win32/registry.rb b/ext/dl/win32/lib/win32/registry.rb
index 9a2f3827b7..ccdd721818 100644
--- a/ext/dl/win32/lib/win32/registry.rb
+++ b/ext/dl/win32/lib/win32/registry.rb
@@ -337,9 +337,10 @@ module Win32
FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
def initialize(code)
@code = code
- msg = "\0" * 1024
+ msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024
len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
- super msg[0, len].tr("\r", '').chomp
+ msg = msg[0, len].force_encoding(Encoding.find(Encoding.locale_charmap))
+ super msg.tr("\r", '').chomp
end
attr_reader :code
end
diff --git a/ext/dl/win32/lib/win32/resolv.rb b/ext/dl/win32/lib/win32/resolv.rb
index 92336fac28..4e69f58085 100644
--- a/ext/dl/win32/lib/win32/resolv.rb
+++ b/ext/dl/win32/lib/win32/resolv.rb
@@ -82,10 +82,14 @@ if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
reg.open(iface) do |regif|
begin
[ 'NameServer', 'DhcpNameServer' ].each do |key|
- ns = regif.read_s(key)
- unless ns.empty?
- nameserver.concat(ns.split(/[,\s]\s*/))
- break
+ begin
+ ns = regif.read_s(key)
+ rescue
+ else
+ unless ns.empty?
+ nameserver.concat(ns.split(/[,\s]\s*/))
+ break
+ end
end
end
rescue Registry::Error