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

ruby-changes:29797

From: usa <ko1@a...>
Date: Tue, 9 Jul 2013 11:06:25 +0900 (JST)
Subject: [ruby-changes:29797] usa:r41849 (trunk): * ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Regstry#check):

usa	2013-07-09 11:06:13 +0900 (Tue, 09 Jul 2013)

  New Revision: 41849

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41849

  Log:
    * ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Regstry#check):
      should report the position of the error.
    
    * ext/{dl,fiddle}/win32/lib/win32/registry.rb
      (Win32::Regstry#QueryValue): workaround for test-all crash.

  Modified files:
    trunk/ChangeLog
    trunk/ext/dl/win32/lib/win32/registry.rb
    trunk/ext/fiddle/win32/lib/win32/registry.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41848)
+++ ChangeLog	(revision 41849)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jul  9 11:04:35 2013  NAKAMURA Usaku  <usa@r...>
+
+	* ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Regstry#check):
+	  should report the position of the error.
+
+	* ext/{dl,fiddle}/win32/lib/win32/registry.rb
+	  (Win32::Regstry#QueryValue): workaround for test-all crash.
+
 Tue Jul  9 10:27:56 2013  NAKAMURA Usaku  <usa@r...>
 
 	* ext/{dl,fiddle}/win32/lib/win32/registry.rb
Index: ext/dl/win32/lib/win32/registry.rb
===================================================================
--- ext/dl/win32/lib/win32/registry.rb	(revision 41848)
+++ ext/dl/win32/lib/win32/registry.rb	(revision 41849)
@@ -232,7 +232,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/dl/win32/lib/win32/registry.rb#L232
       module_function
 
       def check(result)
-        raise Error, result, caller(2) if result != 0
+        raise Error, result, caller(1) if result != 0
       end
 
       def packdw(dw)
@@ -283,13 +283,18 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/dl/win32/lib/win32/registry.rb#L283
       end
 
       def QueryValue(hkey, name)
-        type = packdw(0)
-        size = packdw(0)
-        name = name.encode(WCHAR)
-        check RegQueryValueExW.call(hkey, name, 0, type, 0, size)
-        data = WCHAR_SPACE * unpackdw(size)
-        check RegQueryValueExW.call(hkey, name, 0, type, data, size)
-        [ unpackdw(type), data[0, unpackdw(size)].encode ]
+        prev_gc = GC.disable
+        begin
+          type = packdw(0)
+          size = packdw(0)
+          name = name.encode(WCHAR)
+          check RegQueryValueExW.call(hkey, name, 0, type, 0, size)
+          data = WCHAR_SPACE * unpackdw(size)
+          check RegQueryValueExW.call(hkey, name, 0, type, data, size)
+          [ unpackdw(type), data[0, unpackdw(size)].encode ]
+        ensure
+          GC.enable if prev_gc
+        end
       end
 
       def SetValue(hkey, name, type, data, size)
Index: ext/fiddle/win32/lib/win32/registry.rb
===================================================================
--- ext/fiddle/win32/lib/win32/registry.rb	(revision 41848)
+++ ext/fiddle/win32/lib/win32/registry.rb	(revision 41849)
@@ -232,7 +232,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/fiddle/win32/lib/win32/registry.rb#L232
       module_function
 
       def check(result)
-        raise Error, result, caller(2) if result != 0
+        raise Error, result, caller(1) if result != 0
       end
 
       def packdw(dw)
@@ -283,13 +283,18 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/fiddle/win32/lib/win32/registry.rb#L283
       end
 
       def QueryValue(hkey, name)
-        type = packdw(0)
-        size = packdw(0)
-        name = name.encode(WCHAR)
-        check RegQueryValueExW.call(hkey, name, 0, type, 0, size)
-        data = WCHAR_SPACE * unpackdw(size)
-        check RegQueryValueExW.call(hkey, name, 0, type, data, size)
-        [ unpackdw(type), data[0, unpackdw(size)].encode ]
+        prev_gc = GC.disable
+        begin
+          type = packdw(0)
+          size = packdw(0)
+          name = name.encode(WCHAR)
+          check RegQueryValueExW.call(hkey, name, 0, type, 0, size)
+          data = WCHAR_SPACE * unpackdw(size)
+          check RegQueryValueExW.call(hkey, name, 0, type, data, size)
+          [ unpackdw(type), data[0, unpackdw(size)].encode ]
+        ensure
+          GC.enable if prev_gc
+        end
       end
 
       def SetValue(hkey, name, type, data, size)

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

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