summaryrefslogtreecommitdiff
path: root/zen/zstring.cpp
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-09-01 00:24:17 +0000
committerB Stack <bgstack15@gmail.com>2020-09-01 00:24:17 +0000
commit5a3f52b016581a6a0cb4513614b6c620d365dde2 (patch)
treeacfdfb3e1046db87040477033fda0df76d92916a /zen/zstring.cpp
parentMerge branch '11.0' into 'master' (diff)
parentadd upstream 11.1 (diff)
downloadFreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.tar.gz
FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.tar.bz2
FreeFileSync-5a3f52b016581a6a0cb4513614b6c620d365dde2.zip
Merge branch '11.1' into 'master'11.1
add upstream 11.1 See merge request opensource-tracking/FreeFileSync!25
Diffstat (limited to 'zen/zstring.cpp')
-rw-r--r--zen/zstring.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/zen/zstring.cpp b/zen/zstring.cpp
index b78bc118..06c839e3 100644
--- a/zen/zstring.cpp
+++ b/zen/zstring.cpp
@@ -16,11 +16,14 @@ using namespace zen;
Zstring getUpperCase(const Zstring& str)
{
+ assert(str.find(Zchar('\0')) == Zstring::npos); //don't expect embedded nulls!
+
//fast pre-check:
if (isAsciiString(str)) //perf: in the range of 3.5ns
{
Zstring output = str;
- for (Zchar& c : output) c = asciiToUpper(c);
+ for (Zchar& c : output)
+ c = asciiToUpper(c);
return output;
}
@@ -31,7 +34,7 @@ Zstring getUpperCase(const Zstring& str)
Zstring output;
output.reserve(strNorm.size());
- impl::UtfDecoder<char> decoder(strNorm.c_str(), strNorm.size());
+ UtfDecoder<char> decoder(strNorm.c_str(), strNorm.size());
while (const std::optional<impl::CodePoint> cp = decoder.getNext())
impl::codePointToUtf<char>(::g_unichar_toupper(*cp), [&](char c) { output += c; }); //don't use std::towupper: *incomplete* and locale-dependent!
@@ -77,6 +80,7 @@ Zstring replaceCpyAsciiNoCase(const Zstring& str, const Zstring& oldTerm, const
if (oldTerm.empty())
return str;
+ //assert(isAsciiString(oldTerm));
Zstring output;
for (size_t pos = 0;;)
@@ -139,8 +143,8 @@ int compareNoCaseUtf8(const char* lhs, size_t lhsLen, const char* rhs, size_t rh
//- wcsncasecmp: https://opensource.apple.com/source/Libc/Libc-763.12/string/wcsncasecmp-fbsd.c
// => re-implement comparison based on g_unichar_tolower() to avoid memory allocations
- impl::UtfDecoder<char> decL(lhs, lhsLen);
- impl::UtfDecoder<char> decR(rhs, rhsLen);
+ UtfDecoder<char> decL(lhs, lhsLen);
+ UtfDecoder<char> decR(rhs, rhsLen);
for (;;)
{
const std::optional<impl::CodePoint> cpL = decL.getNext();
bgstack15