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

ruby-changes:29795

From: usa <ko1@a...>
Date: Tue, 9 Jul 2013 10:30:59 +0900 (JST)
Subject: [ruby-changes:29795] usa:r41847 (trunk): * ext/{dl,fiddle}/win32/lib/win32/registry.rb

usa	2013-07-09 10:30:47 +0900 (Tue, 09 Jul 2013)

  New Revision: 41847

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

  Log:
    * ext/{dl,fiddle}/win32/lib/win32/registry.rb
      (Win32::Registry.expand_environ): use suitable encoding for the
      string.
    
    * ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Registry#read):
      should return REG_SZ, REG_EXPAND_SZ and REG_MULTI_SZ values with
      the expected encoding -- assumed as the same encoding of name.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41846)
+++ ChangeLog	(revision 41847)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jul  9 10:27:56 2013  NAKAMURA Usaku  <usa@r...>
+
+	* ext/{dl,fiddle}/win32/lib/win32/registry.rb
+	  (Win32::Registry.expand_environ): use suitable encoding for the
+	  string.
+
+	* ext/{dl,fiddle}/win32/lib/win32/registry.rb (Win32::Registry#read):
+	  should return REG_SZ, REG_EXPAND_SZ and REG_MULTI_SZ values with
+	  the expected encoding -- assumed as the same encoding of name.
+
 Tue Jul  9 10:02:45 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 41846)
+++ ext/dl/win32/lib/win32/registry.rb	(revision 41847)
@@ -340,7 +340,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/dl/win32/lib/win32/registry.rb#L340
     # For detail, see expandEnvironmentStrings[http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp] \Win32 \API.
     #
     def self.expand_environ(str)
-      str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) { ENV[$1] || ENV[$1.upcase] || $& }
+      str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) { (e = ENV[$1.encode(locale)], e.encode(str.encoding) if e) || (e = ENV[$1.encode(locale).upcase], e.encode(str.encoding) if e) || $& }
     end
 
     @@type2name = { }
@@ -600,9 +600,9 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/dl/win32/lib/win32/registry.rb#L600
       end
       case type
       when REG_SZ, REG_EXPAND_SZ
-        [ type, data.chop ]
+        [ type, data.encode(name.encoding).rstrip ]
       when REG_MULTI_SZ
-        [ type, data.split(/\0/) ]
+        [ type, data.encode(name.encoding).split(/\0/) ]
       when REG_BINARY
         [ type, data ]
       when REG_DWORD
Index: ext/fiddle/win32/lib/win32/registry.rb
===================================================================
--- ext/fiddle/win32/lib/win32/registry.rb	(revision 41846)
+++ ext/fiddle/win32/lib/win32/registry.rb	(revision 41847)
@@ -340,7 +340,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/fiddle/win32/lib/win32/registry.rb#L340
     # For detail, see expandEnvironmentStrings[http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp] \Win32 \API.
     #
     def self.expand_environ(str)
-      str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) { ENV[$1] || ENV[$1.upcase] || $& }
+      str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) { (e = ENV[$1.encode(locale)], e.encode(str.encoding) if e) || (e = ENV[$1.encode(locale).upcase], e.encode(str.encoding) if e) || $& }
     end
 
     @@type2name = { }
@@ -600,9 +600,9 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/fiddle/win32/lib/win32/registry.rb#L600
       end
       case type
       when REG_SZ, REG_EXPAND_SZ
-        [ type, data.chop ]
+        [ type, data.encode(name.encoding).rstrip ]
       when REG_MULTI_SZ
-        [ type, data.split(/\0/) ]
+        [ type, data.encode(name.encoding).split(/\0/) ]
       when REG_BINARY
         [ type, data ]
       when REG_DWORD

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

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