use std::size_t
This commit is contained in:
committed by
Max Kellermann
parent
fe6abe1750
commit
3456b1e50d
@@ -167,7 +167,7 @@ ValidateUTF8(const char *p) noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t
|
||||
std::size_t
|
||||
SequenceLengthUTF8(char ch) noexcept
|
||||
{
|
||||
if (IsASCII(ch))
|
||||
@@ -194,7 +194,7 @@ SequenceLengthUTF8(char ch) noexcept
|
||||
|
||||
}
|
||||
|
||||
template<size_t L>
|
||||
template<std::size_t L>
|
||||
struct CheckSequenceUTF8 {
|
||||
gcc_pure
|
||||
bool operator()(const char *p) const noexcept {
|
||||
@@ -209,9 +209,9 @@ struct CheckSequenceUTF8<0U> {
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t L>
|
||||
template<std::size_t L>
|
||||
gcc_pure
|
||||
static size_t
|
||||
static std::size_t
|
||||
InnerSequenceLengthUTF8(const char *p) noexcept
|
||||
{
|
||||
return CheckSequenceUTF8<L>()(p)
|
||||
@@ -219,7 +219,7 @@ InnerSequenceLengthUTF8(const char *p) noexcept
|
||||
: 0U;
|
||||
}
|
||||
|
||||
size_t
|
||||
std::size_t
|
||||
SequenceLengthUTF8(const char *p) noexcept
|
||||
{
|
||||
const uint8_t ch = *p++;
|
||||
@@ -258,14 +258,14 @@ FindNonASCIIOrZero(const char *p) noexcept
|
||||
|
||||
const char *
|
||||
Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer,
|
||||
size_t buffer_size) noexcept
|
||||
std::size_t buffer_size) noexcept
|
||||
{
|
||||
const char *p = FindNonASCIIOrZero(src);
|
||||
if (*p == 0)
|
||||
/* everything is plain ASCII, we don't need to convert anything */
|
||||
return src;
|
||||
|
||||
if ((size_t)(p - src) >= buffer_size)
|
||||
if ((std::size_t)(p - src) >= buffer_size)
|
||||
/* buffer too small */
|
||||
return nullptr;
|
||||
|
||||
@@ -332,14 +332,14 @@ UnicodeToUTF8(unsigned ch, char *q) noexcept
|
||||
return q;
|
||||
}
|
||||
|
||||
size_t
|
||||
std::size_t
|
||||
LengthUTF8(const char *p) noexcept
|
||||
{
|
||||
/* this is a very naive implementation: it does not do any
|
||||
verification, it just counts the bytes that are not a UTF-8
|
||||
continuation */
|
||||
|
||||
size_t n = 0;
|
||||
std::size_t n = 0;
|
||||
for (; *p != 0; ++p)
|
||||
if (!IsContinuation(*p))
|
||||
++n;
|
||||
|
||||
@@ -47,7 +47,7 @@ ValidateUTF8(const char *p) noexcept;
|
||||
* character, or 0 if the character is not a valid start byte
|
||||
*/
|
||||
gcc_const
|
||||
size_t
|
||||
std::size_t
|
||||
SequenceLengthUTF8(char ch) noexcept;
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ SequenceLengthUTF8(char ch) noexcept;
|
||||
* if the sequence is malformed
|
||||
*/
|
||||
gcc_pure
|
||||
size_t
|
||||
std::size_t
|
||||
SequenceLengthUTF8(const char *p) noexcept;
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ SequenceLengthUTF8(const char *p) noexcept;
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
const char *
|
||||
Latin1ToUTF8(const char *src, char *buffer, size_t buffer_size) noexcept;
|
||||
Latin1ToUTF8(const char *src, char *buffer, std::size_t buffer_size) noexcept;
|
||||
|
||||
/**
|
||||
* Convert the specified Unicode character to UTF-8 and write it to
|
||||
@@ -84,7 +84,7 @@ UnicodeToUTF8(unsigned ch, char *buffer) noexcept;
|
||||
* from strlen(), which counts the number of bytes.
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
size_t
|
||||
std::size_t
|
||||
LengthUTF8(const char *p) noexcept;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user