1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/win32ole/win32ole.c (reg_get_val): expand environment in

the pathname. [Bug #3907]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2010-10-14 11:56:10 +00:00
parent 694826d7e2
commit b1085abaeb
3 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Oct 14 20:50:51 2010 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (reg_get_val): expand environment in
the pathname. [Bug #3907]
Thu Oct 14 07:35:07 2010 NARUSE, Yui <naruse@ruby-lang.org> Thu Oct 14 07:35:07 2010 NARUSE, Yui <naruse@ruby-lang.org>
* file.c (DEVT2NUM): added. Size of dev_t is depend on the * file.c (DEVT2NUM): added. Size of dev_t is depend on the

View file

@ -143,7 +143,7 @@ const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00,
#define WC2VSTR(x) ole_wc2vstr((x), TRUE) #define WC2VSTR(x) ole_wc2vstr((x), TRUE)
#define WIN32OLE_VERSION "1.5.0" #define WIN32OLE_VERSION "1.5.1"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@ -2338,6 +2338,13 @@ reg_get_val(HKEY hkey, const char *subkey)
err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, pbuf, &size); err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, pbuf, &size);
if (err == ERROR_SUCCESS) { if (err == ERROR_SUCCESS) {
pbuf[size] = '\0'; 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); val = rb_str_new2(pbuf);
} }
free(pbuf); free(pbuf);

View file

@ -46,6 +46,12 @@ if defined?(WIN32OLE_TYPELIB)
} }
end 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 def test_guid
tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid) assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid)