summaryrefslogtreecommitdiff
path: root/zen/zstring.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:23:48 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:23:48 +0200
commitee1c8c5c25d25dfa42120125a8a45dc9831ee412 (patch)
tree67aa287157db954e0cadeee05b4aad331eb2ecf2 /zen/zstring.cpp
parent5.13 (diff)
downloadFreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.gz
FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.bz2
FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.zip
5.14
Diffstat (limited to 'zen/zstring.cpp')
-rw-r--r--zen/zstring.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/zen/zstring.cpp b/zen/zstring.cpp
index b371e598..262df49e 100644
--- a/zen/zstring.cpp
+++ b/zen/zstring.cpp
@@ -12,6 +12,7 @@
#include "win_ver.h"
#elif defined FFS_MAC
+//#include <zen/scope_guard.h>
#include <ctype.h> //toupper()
#endif
@@ -132,7 +133,7 @@ time per call | function
#ifdef FFS_WIN
namespace
{
-#ifndef LOCALE_INVARIANT //not known to MinGW
+#ifdef __MINGW32__ //MinGW is clueless...
#define LOCALE_INVARIANT 0x007f
#endif
@@ -169,7 +170,7 @@ int z_impl::compareFilenamesNoCase(const wchar_t* lhs, const wchar_t* rhs, size_
}
else //fallback
{
- //do NOT use "CompareString"; this function is NOT accurate (even with LOCALE_INVARIANT and SORT_STRINGSORT): for example "weiß" == "weiss"!!!
+ //do NOT use "CompareString"; this function is NOT accurate (even with LOCALE_INVARIANT and SORT_STRINGSORT): for example "weiß" == "weiss"!!!
//the only reliable way to compare filenames (with XP) is to call "CharUpper" or "LCMapString":
const auto minSize = static_cast<unsigned int>(std::min(sizeLhs, sizeRhs));
@@ -229,9 +230,16 @@ void z_impl::makeFilenameUpperCase(wchar_t* str, size_t size)
}
#elif defined FFS_MAC
+int z_impl::compareFilenamesNoCase(const char* lhs, const char* rhs, size_t sizeLhs, size_t sizeRhs)
+{
+ return ::strcasecmp(lhs, rhs); //locale-dependent!
+}
+
+
void z_impl::makeFilenameUpperCase(char* str, size_t size)
{
std::for_each(str, str + size, [](char& c) { c = static_cast<char>(::toupper(static_cast<unsigned char>(c))); }); //locale-dependent!
//result of toupper() is an unsigned char mapped to int range, so the char representation is in the last 8 bits and we need not care about signedness!
+ //this should work for UTF-8, too: all chars >= 128 are mapped upon themselves!
}
#endif
bgstack15