ruby-changes:49777
From: nobu <ko1@a...>
Date: Thu, 18 Jan 2018 10:10:26 +0900 (JST)
Subject: [ruby-changes:49777] nobu:r61895 (trunk): win32/resolv.rb: call rb_w32_osid
nobu 2018-01-18 10:10:22 +0900 (Thu, 18 Jan 2018) New Revision: 61895 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61895 Log: win32/resolv.rb: call rb_w32_osid * ext/win32/lib/win32/resolv.rb: call rb_w32_osid instead of direct GetVersionExA API. Modified files: trunk/ext/win32/lib/win32/resolv.rb Index: ext/win32/lib/win32/resolv.rb =================================================================== --- ext/win32/lib/win32/resolv.rb (revision 61894) +++ ext/win32/lib/win32/resolv.rb (revision 61895) @@ -42,19 +42,19 @@ begin https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/resolv.rb#L42 rescue LoadError end -nt = Module.new do - break true if [nil].pack("p").size > 4 - extend Importer - dlload "kernel32.dll" - getv = extern "int GetVersionExA(void *)", :stdcall - info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128 - getv.call(info) - break info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT +if [nil].pack("p").size <= 4 # 32bit env + begin + f = Fiddle + osid = f::Handle.new["rb_w32_osid"] + rescue f::DLError # not ix86, cannot be Windows 9x + else + if f::Function.new(osid, [], f::TYPE_INT).call < 2 # VER_PLATFORM_WIN32_NT + require_relative 'resolv9x' + return + end + end end -if not nt - require_relative 'resolv9x' - # return # does not work yet -else + module Win32 #==================================================================== # Windows NT @@ -146,4 +146,3 @@ module Win32 https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/resolv.rb#L146 end end end -end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/