summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-05 23:52:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-05 23:52:52 +0000
commita237db5cbc3e3093330c20b26a97320262ee7b16 (patch)
treedc1794798e74212781ace6bb38408ca1be9ac604 /dln.c
parentacfd09ed83bd9ee347870eac99f75d2579162e4c (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.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/dln.c b/dln.c
index 1f93950..b3522f1 100644
--- a/dln.c
+++ b/dln.c
@@ -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;
}