aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/Windows/Path.inc
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-10-07 01:00:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-10-07 01:00:07 +0000
commit6a971bb8f59f4e20c953a2cc360cab7bae8642e4 (patch)
treef3784bd1d13b1987a65df2b1d1a06830e9eeed88 /lib/Support/Windows/Path.inc
parent32e3150faba95187c76b211e27d6496a21bee360 (diff)
downloadexternal_llvm-6a971bb8f59f4e20c953a2cc360cab7bae8642e4.zip
external_llvm-6a971bb8f59f4e20c953a2cc360cab7bae8642e4.tar.gz
external_llvm-6a971bb8f59f4e20c953a2cc360cab7bae8642e4.tar.bz2
Revert "Revert "Windows: Add support for unicode command lines""
This reverts commit r192070 which reverted r192069, I forgot to regenerate the configure scripts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192079 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows/Path.inc')
-rw-r--r--lib/Support/Windows/Path.inc29
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index 94a501b..998ec42 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -128,7 +128,7 @@ retry_random_path:
BYTE val = 0;
if (!::CryptGenRandom(CryptoProvider, 1, &val))
return windows_error(::GetLastError());
- random_path_utf16.push_back("0123456789abcdef"[val & 15]);
+ random_path_utf16.push_back(L"0123456789abcdef"[val & 15]);
}
else
random_path_utf16.push_back(*i);
@@ -241,22 +241,23 @@ TimeValue file_status::getLastModificationTime() const {
}
error_code current_path(SmallVectorImpl<char> &result) {
- SmallVector<wchar_t, 128> cur_path;
- cur_path.reserve(128);
-retry_cur_dir:
- DWORD len = ::GetCurrentDirectoryW(cur_path.capacity(), cur_path.data());
+ SmallVector<wchar_t, MAX_PATH> cur_path;
+ DWORD len = MAX_PATH;
- // A zero return value indicates a failure other than insufficient space.
- if (len == 0)
- return windows_error(::GetLastError());
-
- // If there's insufficient space, the len returned is larger than the len
- // given.
- if (len > cur_path.capacity()) {
+ do {
cur_path.reserve(len);
- goto retry_cur_dir;
- }
+ len = ::GetCurrentDirectoryW(cur_path.capacity(), cur_path.data());
+
+ // A zero return value indicates a failure other than insufficient space.
+ if (len == 0)
+ return windows_error(::GetLastError());
+
+ // If there's insufficient space, the len returned is larger than the len
+ // given.
+ } while (len > cur_path.capacity());
+ // On success, GetCurrentDirectoryW returns the number of characters not
+ // including the null-terminator.
cur_path.set_size(len);
return UTF16ToUTF8(cur_path.begin(), cur_path.size(), result);
}