mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	win32/registry.rb: size in bytes
* ext/win32/lib/win32/registry.rb (Win32::Registry#write): data size is in bytes, not chars. terminators should be placed automatically. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									79e880c90d
								
							
						
					
					
						commit
						360c66732c
					
				
					 2 changed files with 11 additions and 3 deletions
				
			
		|  | @ -1,3 +1,8 @@ | |||
| Tue Sep 24 16:41:15 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org> | ||||
| 
 | ||||
| 	* ext/win32/lib/win32/registry.rb (Win32::Registry#write): data size | ||||
| 	  is in bytes, not chars.  terminators should be placed automatically. | ||||
| 
 | ||||
| Tue Sep 24 16:39:36 2013  Nobuyoshi Nakada  <nobu@ruby-lang.org> | ||||
| 
 | ||||
| 	* ext/win32/lib/win32/registry.rb (Win32::Registry#each_value): encode | ||||
|  |  | |||
|  | @ -725,11 +725,14 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr | |||
|     # method returns. | ||||
|     # | ||||
|     def write(name, type, data) | ||||
|       termsize = 0 | ||||
|       case type | ||||
|       when REG_SZ, REG_EXPAND_SZ | ||||
|         data = data.to_s + "\0" | ||||
|         data = data.encode(WCHAR) | ||||
|         termsize = WCHAR_SIZE | ||||
|       when REG_MULTI_SZ | ||||
|         data = data.to_a.join("\0") + "\0\0" | ||||
|         data = data.to_a.map {|s| s.encode(WCHAR)}.join(WCHAR_NUL) << WCHAR_NUL | ||||
|         termsize = WCHAR_SIZE | ||||
|       when REG_BINARY | ||||
|         data = data.to_s | ||||
|       when REG_DWORD | ||||
|  | @ -741,7 +744,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr | |||
|       else | ||||
|         raise TypeError, "Unsupported type #{type}" | ||||
|       end | ||||
|       API.SetValue(@hkey, name, type, data, data.length) | ||||
|       API.SetValue(@hkey, name, type, data, data.bytesize + termsize) | ||||
|     end | ||||
| 
 | ||||
|     # | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 nobu
						nobu