tree-wide: use UINT64_MAX or friends

This commit is contained in:
Yu Watanabe
2021-03-05 07:10:13 +09:00
parent ef1e0b9a46
commit f5fbe71d95
150 changed files with 530 additions and 528 deletions
+10 -10
View File
@@ -156,14 +156,14 @@ char *utf8_is_valid_n(const char *str, size_t len_bytes) {
assert(str);
for (const char *p = str; len_bytes != (size_t) -1 ? (size_t) (p - str) < len_bytes : *p != '\0'; ) {
for (const char *p = str; len_bytes != SIZE_MAX ? (size_t) (p - str) < len_bytes : *p != '\0'; ) {
int len;
if (_unlikely_(*p == '\0') && len_bytes != (size_t) -1)
if (_unlikely_(*p == '\0') && len_bytes != SIZE_MAX)
return NULL; /* embedded NUL */
len = utf8_encoded_valid_unichar(p,
len_bytes != (size_t) -1 ? len_bytes - (p - str) : (size_t) -1);
len_bytes != SIZE_MAX ? len_bytes - (p - str) : SIZE_MAX);
if (_unlikely_(len < 0))
return NULL; /* invalid character */
@@ -185,7 +185,7 @@ char *utf8_escape_invalid(const char *str) {
while (*str) {
int len;
len = utf8_encoded_valid_unichar(str, (size_t) -1);
len = utf8_encoded_valid_unichar(str, SIZE_MAX);
if (len > 0) {
s = mempcpy(s, str, len);
str += len;
@@ -233,7 +233,7 @@ char *utf8_escape_non_printable_full(const char *str, size_t console_width) {
if (!*str) /* done! */
goto finish;
len = utf8_encoded_valid_unichar(str, (size_t) -1);
len = utf8_encoded_valid_unichar(str, SIZE_MAX);
if (len > 0) {
if (utf8_is_printable(str, len)) {
int w;
@@ -508,7 +508,7 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
assert(str);
assert(length > 0);
/* We read until NUL, at most length bytes. (size_t) -1 may be used to disable the length check. */
/* We read until NUL, at most length bytes. SIZE_MAX may be used to disable the length check. */
len = utf8_encoded_expected_len(str[0]);
if (len == 0)
@@ -545,14 +545,14 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
size_t utf8_n_codepoints(const char *str) {
size_t n = 0;
/* Returns the number of UTF-8 codepoints in this string, or (size_t) -1 if the string is not valid UTF-8. */
/* Returns the number of UTF-8 codepoints in this string, or SIZE_MAX if the string is not valid UTF-8. */
while (*str != 0) {
int k;
k = utf8_encoded_valid_unichar(str, (size_t) -1);
k = utf8_encoded_valid_unichar(str, SIZE_MAX);
if (k < 0)
return (size_t) -1;
return SIZE_MAX;
str += k;
n++;
@@ -572,7 +572,7 @@ size_t utf8_console_width(const char *str) {
w = utf8_char_console_width(str);
if (w < 0)
return (size_t) -1;
return SIZE_MAX;
n += w;
str = utf8_next_char(str);