Support o3tl::iterateCodePoints with both sal_Int32 and std::size_t
...and clean up the most gross casting offenses Change-Id: If0d646fb3e73e71a9a2735569395034973563a1f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
@@ -266,7 +266,7 @@ sal_Int32 getTokenCount(std::u16string_view rIn, sal_Unicode cTok)
|
||||
sal_uInt32 decimalStringToNumber(std::u16string_view str)
|
||||
{
|
||||
sal_uInt32 result = 0;
|
||||
for( sal_Int32 i = 0; i < static_cast<sal_Int32>(str.size()); )
|
||||
for( std::size_t i = 0; i < str.size(); )
|
||||
{
|
||||
sal_uInt32 c = o3tl::iterateCodePoints(str, &i);
|
||||
sal_uInt32 value = 0;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -111,7 +112,7 @@ namespace {
|
||||
// surrogates, even though they should not appear in well-formed UNO OUString
|
||||
// instances anyway), or is a slash (as it causes problems in path syntax):
|
||||
bool isValidName(std::u16string_view name, bool setMember) {
|
||||
for (sal_Int32 i = 0; i != static_cast<sal_Int32>(name.size());) {
|
||||
for (std::size_t i = 0; i != name.size();) {
|
||||
sal_uInt32 c = o3tl::iterateCodePoints(name, &i);
|
||||
if ((c < 0x20 && !(c == 0x09 || c == 0x0A || c == 0x0D))
|
||||
|| rtl::isSurrogate(c) || c == 0xFFFE || c == 0xFFFF
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include <o3tl/intcmp.hxx>
|
||||
#include <rtl/character.hxx>
|
||||
@@ -509,8 +510,9 @@ inline double toDouble(std::string_view str)
|
||||
}
|
||||
|
||||
// Like OUString::iterateCodePoints, but for std::string_view:
|
||||
inline sal_uInt32 iterateCodePoints(std::u16string_view string, sal_Int32* indexUtf16,
|
||||
sal_Int32 incrementCodePoints = 1)
|
||||
template <typename T>
|
||||
requires(std::is_same_v<T, sal_Int32> || std::is_same_v<T, std::size_t>) sal_uInt32
|
||||
iterateCodePoints(std::u16string_view string, T* indexUtf16, sal_Int32 incrementCodePoints = 1)
|
||||
{
|
||||
std::size_t n;
|
||||
char16_t cu;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <tools/json_writer.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <stdio.h>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <rtl/math.hxx>
|
||||
|
||||
@@ -137,8 +138,8 @@ void JsonWriter::writeEscapedOUString(std::u16string_view rPropVal)
|
||||
++mPos;
|
||||
|
||||
// Convert from UTF-16 to UTF-8 and perform escaping
|
||||
sal_Int32 i = 0;
|
||||
while (i < static_cast<sal_Int32>(rPropVal.size()))
|
||||
std::size_t i = 0;
|
||||
while (i < rPropVal.size())
|
||||
{
|
||||
sal_uInt32 ch = o3tl::iterateCodePoints(rPropVal, &i);
|
||||
if (writeEscapedSequence(ch, mPos))
|
||||
|
||||
Reference in New Issue
Block a user