summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-11-03 10:23:05 -0700
committerKarl Williamson <khw@cpan.org>2019-11-03 13:08:23 -0700
commit00e5307810a49f3c9c1ddf00034cc97c7544681a (patch)
treeffbaffb5453f95a980198f3ad36313dfda403332
parent663043704fc485479f3fc1f0f2bd994b4672a7b4 (diff)
downloadperl-00e5307810a49f3c9c1ddf00034cc97c7544681a.tar.gz
mathoms.c,utf8.c: Update to use UTF8_CHK_SKIP
This new macro expands to what these did. Update to use the common code.
-rw-r--r--mathoms.c5
-rw-r--r--utf8.c20
2 files changed, 7 insertions, 18 deletions
diff --git a/mathoms.c b/mathoms.c
index b34012069f..b0122f95ca 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -1196,8 +1196,9 @@ Perl_is_utf8_char(const U8 *s)
PERL_ARGS_ASSERT_IS_UTF8_CHAR;
/* Assumes we have enough space, which is why this is deprecated. But the
- * strnlen() makes it safe for the common case of NUL-terminated strings */
- return isUTF8_CHAR(s, s + my_strnlen((char *) s, UTF8SKIP(s)));
+ * UTF8_CHK_SKIP(s)) makes it safe for the common case of NUL-terminated
+ * strings */
+ return isUTF8_CHAR(s, s + UTF8_CHK_SKIP(s));
}
/*
diff --git a/utf8.c b/utf8.c
index d73f8c3f43..911214505b 100644
--- a/utf8.c
+++ b/utf8.c
@@ -5204,23 +5204,11 @@ Perl_utf8_to_uvchr(pTHX_ const U8 *s, STRLEN *retlen)
* the character than there are in the input buffer, it can read past the
* end. But we can make it safe if the input string happens to be
* NUL-terminated, as many strings in Perl are, by refusing to read past a
- * NUL. A NUL indicates the start of the next character anyway. If the
- * input isn't NUL-terminated, the function remains unsafe, as it always
- * has been.
- *
- * An initial NUL has to be handled separately, but all ASCIIs can be
- * handled the same way, speeding up this common case */
-
- if (UTF8_IS_INVARIANT(*s)) { /* Assumes 's' contains at least 1 byte */
- if (retlen) {
- *retlen = 1;
- }
- return (UV) *s;
- }
+ * NUL, which is what UTF8_CHK_SKIP() does. A NUL indicates the start of
+ * the next character anyway. If the input isn't NUL-terminated, the
+ * function remains unsafe, as it always has been. */
- return utf8_to_uvchr_buf(s,
- s + my_strnlen((char *) s, UTF8SKIP(s)),
- retlen);
+ return utf8_to_uvchr_buf(s, s + UTF8_CHK_SKIP(s), retlen);
}
/*