summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-03-01 11:53:38 -0700
committerKarl Williamson <khw@cpan.org>2022-03-01 12:06:15 -0700
commitae005663afa8878139a438594b19b16615e4f5df (patch)
treea87a065b2f696e708bff1ade46b93848b569340f /utf8.h
parentf0ef35deb0072805b68cef82ebe28739f67ca79a (diff)
downloadperl-ae005663afa8878139a438594b19b16615e4f5df.tar.gz
Fix UTF8_IS_REPLACEMENT() and add tests
This macro relied on a now-removed other macro in 2019, 216dc346ceeeb9b6ba0fdd470ccfe4f8b2a286c4. Fix it and add tests. This bug was caught by Devel::PPPort
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/utf8.h b/utf8.h
index 1d172cd626..bd2526ba5d 100644
--- a/utf8.h
+++ b/utf8.h
@@ -917,7 +917,10 @@ representation.
*/
#define UNICODE_REPLACEMENT 0xFFFD
#define UNICODE_IS_REPLACEMENT(uv) UNLIKELY((UV) (uv) == UNICODE_REPLACEMENT)
-#define UTF8_IS_REPLACEMENT(s, send) is_REPLACEMENT_utf8_safe(s,send)
+#define UTF8_IS_REPLACEMENT(s, send) \
+ UNLIKELY( ((send) - (s)) >= (sizeof(REPLACEMENT_CHARACTER_UTF8) - 1) \
+ && memEQ((s), REPLACEMENT_CHARACTER_UTF8, \
+ sizeof(REPLACEMENT_CHARACTER_UTF8) - 1))
/* Max legal code point according to Unicode */
#define PERL_UNICODE_MAX 0x10FFFF