@@ -49,14 +49,9 @@ static FORCE_INLINE_ATTR bool utf8_range_AsciiIsAscii(unsigned char c)
4949 return c < 128 ;
5050}
5151
52- static FORCE_INLINE_ATTR bool utf8_range_IsTrailByteOk (const char c)
52+ static FORCE_INLINE_ATTR bool utf8_range_IsTrailByteOk (unsigned char c)
5353{
54- return static_cast <int8_t >(c) <= static_cast <int8_t >(0xBF );
55- }
56-
57- static FORCE_INLINE_ATTR bool utf8_range_IsTrailByteOk (const unsigned char c)
58- {
59- return utf8_range_IsTrailByteOk (static_cast <const char >(c));
54+ return c <= static_cast <unsigned char >(0xBF );
6055}
6156
6257/* If return_position is false then it returns 1 if |data| is a valid utf8
@@ -98,7 +93,8 @@ static size_t utf8_range_ValidateUTF8Naive(const char *data, const char *end, in
9893 continue ;
9994 }
10095 /* [C2..DF], [80..BF] -> 2 bytes */
101- if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF && utf8_range_IsTrailByteOk (data[1 ]))
96+ if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF &&
97+ utf8_range_IsTrailByteOk (static_cast <unsigned char >(data[1 ])))
10298 {
10399 codepoint_bytes = 2 ;
104100 continue ;
@@ -168,15 +164,15 @@ static size_t utf8_range_ValidateUTF8Naive(const char *data, const char *end, in
168164static inline int utf8_range_CodepointSkipBackwards (int32_t codepoint_word)
169165{
170166 const int8_t *const codepoint = (const int8_t *)(&codepoint_word);
171- if (!utf8_range_IsTrailByteOk (codepoint[3 ]))
167+ if (!utf8_range_IsTrailByteOk (static_cast < unsigned char >( codepoint[3 ]) ))
172168 {
173169 return 1 ;
174170 }
175- else if (!utf8_range_IsTrailByteOk (codepoint[2 ]))
171+ else if (!utf8_range_IsTrailByteOk (static_cast < unsigned char >( codepoint[2 ]) ))
176172 {
177173 return 2 ;
178174 }
179- else if (!utf8_range_IsTrailByteOk (codepoint[1 ]))
175+ else if (!utf8_range_IsTrailByteOk (static_cast < unsigned char >( codepoint[1 ]) ))
180176 {
181177 return 3 ;
182178 }
0 commit comments