forked from OSchip/llvm-project
[support] Revert the changes made to Path.inc for the default Windows code page
Path.inc/widenPath tries to decode the path using both UTF-8 and the default Windows code page. This is no longer necessary with the new InitLLVM method which ensures that the command line arguemnts are already UTF-8 on Windows. llvm-svn: 330266
This commit is contained in:
parent
10831f594a
commit
02caafd7e5
|
@ -63,7 +63,7 @@ namespace llvm {
|
||||||
namespace sys {
|
namespace sys {
|
||||||
namespace path {
|
namespace path {
|
||||||
|
|
||||||
// Convert a (likely) UTF-8 path to UTF-16. Also, if the absolute equivalent of the
|
// Convert a UTF-8 path to UTF-16. Also, if the absolute equivalent of the
|
||||||
// path is longer than CreateDirectory can tolerate, make it absolute and
|
// path is longer than CreateDirectory can tolerate, make it absolute and
|
||||||
// prefixed by '\\?\'.
|
// prefixed by '\\?\'.
|
||||||
std::error_code widenPath(const Twine &Path8,
|
std::error_code widenPath(const Twine &Path8,
|
||||||
|
@ -72,7 +72,7 @@ std::error_code widenPath(const Twine &Path8,
|
||||||
|
|
||||||
// Several operations would convert Path8 to SmallString; more efficient to
|
// Several operations would convert Path8 to SmallString; more efficient to
|
||||||
// do it once up front.
|
// do it once up front.
|
||||||
SmallString<2*MAX_PATH> Path8Str;
|
SmallString<128> Path8Str;
|
||||||
Path8.toVector(Path8Str);
|
Path8.toVector(Path8Str);
|
||||||
|
|
||||||
// If we made this path absolute, how much longer would it get?
|
// If we made this path absolute, how much longer would it get?
|
||||||
|
@ -112,17 +112,11 @@ std::error_code widenPath(const Twine &Path8,
|
||||||
else
|
else
|
||||||
llvm::sys::path::append(FullPath, *I);
|
llvm::sys::path::append(FullPath, *I);
|
||||||
}
|
}
|
||||||
Path8Str = FullPath;
|
return UTF8ToUTF16(FullPath, Path16);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path8Str now contains the full path or the original path
|
// Just use the caller's original path.
|
||||||
// If the conversion from UTF8 to UTF16 fails because of ERROR_NO_UNICODE_TRANSLATION,
|
return UTF8ToUTF16(Path8Str, Path16);
|
||||||
// we also try using the current code page before giving up
|
|
||||||
auto ec = UTF8ToUTF16(Path8Str, Path16);
|
|
||||||
if (ec == mapWindowsError(ERROR_NO_UNICODE_TRANSLATION)) {
|
|
||||||
ec = CurCPToUTF16(Path8Str, Path16);
|
|
||||||
}
|
|
||||||
return ec;
|
|
||||||
}
|
}
|
||||||
} // end namespace path
|
} // end namespace path
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue