mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
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
This commit is contained in:
parent
acfd09ed83
commit
a237db5cbc
5 changed files with 45 additions and 5 deletions
15
dln.c
15
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue