summaryrefslogtreecommitdiff
path: root/zen/string_tools.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-10-11 11:16:39 -0400
committerB. Stack <bgstack15@gmail.com>2022-10-11 11:16:39 -0400
commitcab22f2dc3c5f41b5163f74cbb233e390edff6ff (patch)
treea49cfd729d9793681a57fa6f7409b0f0848e9ede /zen/string_tools.h
parentMerge branch 'b11.25' into 'master' (diff)
downloadFreeFileSync-cab22f2dc3c5f41b5163f74cbb233e390edff6ff.tar.gz
FreeFileSync-cab22f2dc3c5f41b5163f74cbb233e390edff6ff.tar.bz2
FreeFileSync-cab22f2dc3c5f41b5163f74cbb233e390edff6ff.zip
add upstream 11.26
Diffstat (limited to 'zen/string_tools.h')
-rw-r--r--zen/string_tools.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/zen/string_tools.h b/zen/string_tools.h
index 181a3951..364a9a26 100644
--- a/zen/string_tools.h
+++ b/zen/string_tools.h
@@ -263,7 +263,7 @@ bool equalString(const S& lhs, const T& rhs)
template <class S, class T> inline
bool equalAsciiNoCase(const S& lhs, const T& rhs)
{
- //assert(isAsciiString(lhs) || isAsciiString(rhs));
+ //assert(isAsciiString(lhs) || isAsciiString(rhs)); -> no, too strict (e.g. comparing file extensions ASCII-CI)
const size_t lhsLen = strLength(lhs);
return lhsLen == strLength(rhs) && impl::strcmpAsciiNoCase(strBegin(lhs), strBegin(rhs), lhsLen) == std::weak_ordering::equivalent;
}
@@ -627,10 +627,14 @@ S printNumber(const T& format, const Num& number) //format a single number using
#endif
static_assert(std::is_same_v<GetCharTypeT<S>, GetCharTypeT<T>>);
- GetCharTypeT<S> buf[128]; //zero-initialize?
- const int charsWritten = impl::saferPrintf(buf, std::size(buf), strBegin(format), number);
+ S buf(128, static_cast<GetCharTypeT<S>>('0'));
+ const int charsWritten = impl::saferPrintf(buf.data(), buf.size(), strBegin(format), number);
- return 0 < charsWritten && charsWritten < std::ssize(buf) ? S(buf, charsWritten) : S();
+ if (makeUnsigned(charsWritten) > buf.size())
+ return S();
+
+ buf.resize(charsWritten);
+ return buf;
}
bgstack15