summaryrefslogtreecommitdiff
path: root/zen/string_tools.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-10-11 15:17:59 +0000
committerB. Stack <bgstack15@gmail.com>2022-10-11 15:17:59 +0000
commit38c826621a39831d1bdc78aa9e45cc592db3e77f (patch)
treea49cfd729d9793681a57fa6f7409b0f0848e9ede /zen/string_tools.h
parentMerge branch 'b11.25' into 'master' (diff)
parentadd upstream 11.26 (diff)
downloadFreeFileSync-38c826621a39831d1bdc78aa9e45cc592db3e77f.tar.gz
FreeFileSync-38c826621a39831d1bdc78aa9e45cc592db3e77f.tar.bz2
FreeFileSync-38c826621a39831d1bdc78aa9e45cc592db3e77f.zip
Merge branch 'b11.26' into 'master'11.26
add upstream 11.26 See merge request opensource-tracking/FreeFileSync!49
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