diff options
| author | Tannin <devnull@localhost> | 2015-05-17 14:03:01 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2015-05-17 14:03:01 +0200 |
| commit | 268d2ffe8b533890b408740db1a6a3730dfd8597 (patch) | |
| tree | 889aec6383b1880cb99b3cd8ebe014485661d8e5 /src/shared/util.cpp | |
| parent | 9d3364f4da3fe77113147d9350c0e8c8c7f7a637 (diff) | |
- some code cleanup and modernization trying to fix "dr memory" reports
(though they were almost certainly false positives)
- there is now a 50ms timeout on logging messages
- bugfix: leaked handles after directory searches
Diffstat (limited to 'src/shared/util.cpp')
| -rw-r--r-- | src/shared/util.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/shared/util.cpp b/src/shared/util.cpp index e5bcd436..3692aae1 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -109,7 +109,7 @@ std::string &ToLower(std::string &text) std::string ToLower(const std::string &text)
{
- std::string result = text;
+ std::string result(text);
std::transform(result.begin(), result.end(), result.begin(), locToLower);
return result;
}
@@ -122,11 +122,26 @@ std::wstring &ToLower(std::wstring &text) std::wstring ToLower(const std::wstring &text)
{
- std::wstring result = text;
+ std::wstring result(text);
std::transform(result.begin(), result.end(), result.begin(), locToLowerW);
return result;
}
+bool CaseInsenstiveComparePred(wchar_t lhs, wchar_t rhs)
+{
+ return std::tolower(lhs, loc) == std::tolower(rhs, loc);
+}
+
+bool CaseInsensitiveEqual(const std::wstring &lhs, const std::wstring &rhs)
+{
+ return (lhs.length() == rhs.length())
+ && std::equal(lhs.begin(), lhs.end(),
+ rhs.begin(),
+ [] (wchar_t lhs, wchar_t rhs) -> bool {
+ return std::tolower(lhs, loc) == std::tolower(rhs, loc);
+ });
+}
+
VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
{
DWORD handle = 0UL;
|
