utf: ensure neat() is called in utf8_check

This commit is contained in:
anna 2021-07-30 17:40:31 +02:00
parent 9b191d9b9a
commit 0ecf0be554
Signed by: fef
GPG key ID: EC22E476DC2D3D84

View file

@ -17,7 +17,7 @@
usize utf8_check(const char *restrict s, error *err)
{
usize ret = 0;
nchar c;
nchar c = 0xffffffff; /* not a valid Unicode character */
while (*s != '\0') {
ret++;
@ -27,13 +27,16 @@ usize utf8_check(const char *restrict s, error *err)
}
}
if (c == 0xffffffff) /* loop hasn't executed at all */
neat(err);
return ret;
}
usize utf8_ncheck(const char *restrict s, usize maxsize, error *err)
{
usize ret = 0;
nchar c;
nchar c = 0xffffffff; /* not a valid Unicode character */
while (*s != '\0' && maxsize != 0) {
ret++;
@ -45,6 +48,9 @@ usize utf8_ncheck(const char *restrict s, usize maxsize, error *err)
}
}
if (c == 0xffffffff) /* loop hasn't executed at all */
neat(err);
return ret;
}