diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-05 23:52:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-04-05 23:52:52 +0000 |
commit | a237db5cbc3e3093330c20b26a97320262ee7b16 (patch) | |
tree | dc1794798e74212781ace6bb38408ca1be9ac604 /dln.c | |
parent | acfd09ed83bd9ee347870eac99f75d2579162e4c (diff) |
dln.c: non-ascii path on Windows
* dln.c (dln_load): use wchar version to load a library in
non-ascii path on Windows. based on the patch by Bugra Barin
<bugrabarin AT hotmail.com> in [ruby-core:61845]. [Bug #9699]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r-- | dln.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -1256,20 +1256,25 @@ dln_load(const char *file) #if defined _WIN32 && !defined __CYGWIN__ HINSTANCE handle; - char winfile[MAXPATHLEN]; + WCHAR *winfile; char message[1024]; void (*init_fct)(); char *buf; - if (strlen(file) >= MAXPATHLEN) dln_loaderror("filename too long"); - /* Load the file as an object one */ init_funcname(&buf, file); - strlcpy(winfile, file, sizeof(winfile)); + /* Convert the file path to wide char */ + winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL); + if (!winfile) { + dln_memerror(); + } /* Load file */ - if ((handle = LoadLibrary(winfile)) == NULL) { + handle = LoadLibraryW(winfile); + free(winfile); + + if (!handle) { error = dln_strerror(); goto failed; } |