summaryrefslogtreecommitdiff
path: root/Source/kwsys/DynamicLoader.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-11-25 11:19:42 -0500
committerBrad King <brad.king@kitware.com>2013-11-25 11:19:42 -0500
commitf668112039798f5ebc955e127f9c3e4e7cdb5cc4 (patch)
treec08b9117d4d6288c7dd34af6cbffd7e0314188a7 /Source/kwsys/DynamicLoader.cxx
parentda6b86f4f031b189768dc474721145a1b99f71ea (diff)
parent704ab3d24827cfe5754a00028086f21503c2e08b (diff)
downloadcmake-f668112039798f5ebc955e127f9c3e4e7cdb5cc4.tar.gz
Merge branch 'upstream-kwsys' into update-kwsys
Diffstat (limited to 'Source/kwsys/DynamicLoader.cxx')
-rw-r--r--Source/kwsys/DynamicLoader.cxx19
1 files changed, 6 insertions, 13 deletions
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index fd83752c00..44cf6af7e8 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -186,13 +186,12 @@ namespace KWSYS_NAMESPACE
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname)
{
DynamicLoader::LibraryHandle lh;
-#ifdef UNICODE
- wchar_t libn[MB_CUR_MAX];
- mbstowcs(libn, libname, MB_CUR_MAX);
- lh = LoadLibrary(libn);
-#else
- lh = LoadLibrary(libname);
-#endif
+ int length = MultiByteToWideChar(CP_UTF8, 0, libname, -1, NULL, 0);
+ wchar_t* wchars = new wchar_t[length+1];
+ wchars[0] = '\0';
+ MultiByteToWideChar(CP_UTF8, 0, libname, -1, wchars, length);
+ lh = LoadLibraryW(wchars);
+ delete [] wchars;
return lh;
}
@@ -238,13 +237,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
#else
const char *rsym = sym;
#endif
-#ifdef UNICODE
- wchar_t wsym[MB_CUR_MAX];
- mbstowcs(wsym, rsym, MB_CUR_MAX);
- result = GetProcAddress(lib, wsym);
-#else
result = (void*)GetProcAddress(lib, rsym);
-#endif
#if defined(__BORLANDC__) || defined(__WATCOMC__)
delete[] rsym;
#endif