diff --git a/src/c-utf8.c b/src/c-utf8.c index dcd2dbc..c6ed627 100644 --- a/src/c-utf8.c +++ b/src/c-utf8.c @@ -38,7 +38,7 @@ static inline int c_utf8_word_is_ascii(size_t word) { */ _c_public_ void c_utf8_verify_ascii(const char **strp, size_t *lenp) { const char *str = *strp; - size_t len = lenp ? *lenp : (size_t)-1; + size_t len = lenp ? *lenp : strlen (str); while (len > 0 && c_load_8(str, 0) < 128) { if ((void*)c_align_to((unsigned long)str, sizeof(size_t)) == str) { @@ -105,7 +105,7 @@ _c_public_ void c_utf8_verify_ascii(const char **strp, size_t *lenp) { */ _c_public_ void c_utf8_verify(const char **strp, size_t *lenp) { const char *str = *strp; - size_t len = lenp ? *lenp : (size_t)-1; + size_t len = lenp ? *lenp : strlen (str); /* See Unicode 10.0.0, Chapter 3, Section D92 */ diff --git a/src/test-api.c b/src/test-api.c index 599b476..f10c295 100644 --- a/src/test-api.c +++ b/src/test-api.c @@ -19,6 +19,9 @@ static void test_api(void) { c_utf8_verify_ascii(&string1, &n_string1); c_utf8_verify(&string2, &n_string2); + + c_utf8_verify_ascii(&string1, NULL); + c_utf8_verify(&string2, NULL); } int main(int argc, char **argv) {