diff options
author | Karl Williamson <khw@cpan.org> | 2022-03-01 11:53:38 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-03-01 12:06:15 -0700 |
commit | ae005663afa8878139a438594b19b16615e4f5df (patch) | |
tree | a87a065b2f696e708bff1ade46b93848b569340f /utf8.h | |
parent | f0ef35deb0072805b68cef82ebe28739f67ca79a (diff) | |
download | perl-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.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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 |