fix: replaceInPlace() std::wstring #4713

This commit is contained in:
Günter Obiltschnig 2024-09-28 11:38:35 +02:00
parent a525065ebc
commit a5d6034ab9

View File

@ -21,17 +21,48 @@
#include "Poco/Foundation.h"
#include "Poco/Ascii.h"
#include <cstring>
#include <cwchar>
#include <algorithm>
// ignore loop unrolling warnings in this file
#if defined(__clang__) && ((__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ >= 6))
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpass-failed"
#endif
namespace Poco {
template <typename C>
std::size_t cstrlen(const C* str)
/// Returns the length of a zero-terminated C string.
/// For char and wchar_t based strings, overloads are
/// provided that call strlen() and wcslen().
{
const C* end = str;
while (*end) ++end;
return end - str;
}
inline std::size_t cstrlen(const char* str)
/// Returns the length of a zero-terminated C string.
/// This implementation calls std::strlen().
{
return std::strlen(str);
}
inline std::size_t cstrlen(const wchar_t* str)
/// Returns the length of a zero-terminated C string.
/// This implementation calls std::wcslen().
{
return std::wcslen(str);
}
template <class S>
S trimLeft(const S& str)
/// Returns a copy of str with all leading
@ -494,7 +525,7 @@ S& replaceInPlace(S& str, const typename S::value_type* from, const typename S::
S result;
typename S::size_type pos = 0;
typename S::size_type fromLen = std::strlen(from);
typename S::size_type fromLen = cstrlen(from);
result.append(str, 0, start);
do
{