diff options
author | Liang Qi <liang.qi@qt.io> | 2017-07-04 15:29:25 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-07-04 15:30:15 +0200 |
commit | db2ecc45564609f940ff564e777f76a1a4b734d4 (patch) | |
tree | d4756dffb486a2a1c64f13402bafd0327b7ddbb3 /Source/JavaScriptCore/jsc.cpp | |
parent | 8231f9776c2e4028937411bd2a0886aa72c97831 (diff) | |
parent | d10511e0a3f655ab2b1dfebfd9c17ade151a7cfe (diff) |
Merge remote-tracking branch 'origin/5.212' into dev
Change-Id: I006cd9023fadc5407bbaa2ddfda45cb8e88b548b
Diffstat (limited to 'Source/JavaScriptCore/jsc.cpp')
-rw-r--r-- | Source/JavaScriptCore/jsc.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp index d9f888fb1..c0a84fc5f 100644 --- a/Source/JavaScriptCore/jsc.cpp +++ b/Source/JavaScriptCore/jsc.cpp @@ -68,6 +68,7 @@ #if OS(WINDOWS) #include <direct.h> +#include <wtf/text/win/WCharStringExtras.h> #else #include <unistd.h> #endif @@ -868,8 +869,7 @@ static bool currentWorkingDirectory(DirectoryName& directoryName) // https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407.aspx auto buffer = std::make_unique<wchar_t[]>(bufferLength); DWORD lengthNotIncludingNull = ::GetCurrentDirectoryW(bufferLength, buffer.get()); - static_assert(sizeof(wchar_t) == sizeof(UChar), "In Windows, both are UTF-16LE"); - String directoryString = String(reinterpret_cast<UChar*>(buffer.get())); + String directoryString = wcharToString(buffer.get(), lengthNotIncludingNull); // We don't support network path like \\host\share\<path name>. if (directoryString.startsWith("\\\\")) return false; @@ -999,9 +999,7 @@ static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector<char>& // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#maxpath // Use long UNC to pass the long path name to the Windows APIs. String longUNCPathName = WTF::makeString("\\\\?\\", fileName); - static_assert(sizeof(wchar_t) == sizeof(UChar), "In Windows, both are UTF-16LE"); - auto utf16Vector = longUNCPathName.charactersWithNullTermination(); - FILE* f = _wfopen(reinterpret_cast<wchar_t*>(utf16Vector.data()), L"rb"); + FILE* f = _wfopen(stringToNullTerminatedWChar(longUNCPathName).data(), L"rb"); #else FILE* f = fopen(fileName.utf8().data(), "r"); #endif |