ruby-changes:17490
From: suke <ko1@a...>
Date: Thu, 14 Oct 2010 20:56:18 +0900 (JST)
Subject: [ruby-changes:17490] Ruby:r29495 (trunk): * ext/win32ole/win32ole.c (reg_get_val): expand environment in
suke 2010-10-14 20:56:10 +0900 (Thu, 14 Oct 2010) New Revision: 29495 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29495 Log: * ext/win32ole/win32ole.c (reg_get_val): expand environment in the pathname. [Bug #3907] Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole.c trunk/test/win32ole/test_win32ole_typelib.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29494) +++ ChangeLog (revision 29495) @@ -1,3 +1,8 @@ +Thu Oct 14 20:50:51 2010 Masaki Suketa <masaki.suketa@n...> + + * ext/win32ole/win32ole.c (reg_get_val): expand environment in + the pathname. [Bug #3907] + Thu Oct 14 07:35:07 2010 NARUSE, Yui <naruse@r...> * file.c (DEVT2NUM): added. Size of dev_t is depend on the Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 29494) +++ ext/win32ole/win32ole.c (revision 29495) @@ -143,7 +143,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "1.5.0" +#define WIN32OLE_VERSION "1.5.1" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -2338,6 +2338,13 @@ err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, pbuf, &size); if (err == ERROR_SUCCESS) { pbuf[size] = '\0'; + if (dwtype == REG_EXPAND_SZ) { + char* pbuf2 = pbuf; + DWORD len = ExpandEnvironmentStrings(pbuf2, NULL, 0); + pbuf = ALLOC_N(char, len + 1); + ExpandEnvironmentStrings(pbuf2, pbuf, len + 1); + free(pbuf2); + } val = rb_str_new2(pbuf); } free(pbuf); Index: test/win32ole/test_win32ole_typelib.rb =================================================================== --- test/win32ole/test_win32ole_typelib.rb (revision 29494) +++ test/win32ole/test_win32ole_typelib.rb (revision 29495) @@ -46,6 +46,12 @@ } end + # #Bug:3907 [ruby-dev:42338] + def test_initialize_with_REG_EXPAND_SZ + tlib = WIN32OLE_TYPELIB.new("Disk Management Snap-In Object Library") + assert_instance_of(WIN32OLE_TYPELIB, tlib) + end + def test_guid tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/