* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2013-07-09 01:30:47 +00:00
Родитель d9194a4604
Коммит b16b5afa24
3 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Tue Jul 9 10:27:56 2013 NAKAMURA Usaku <usa@ruby-lang.org>
* 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@ruby-lang.org>
* ext/{dl,fiddle}/win32/lib/win32/registry.rb

Просмотреть файл

@ -340,7 +340,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
# 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.microsoft.com/library/en-us/sysinfo/base/pr
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

Просмотреть файл

@ -340,7 +340,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
# 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.microsoft.com/library/en-us/sysinfo/base/pr
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