From: Karl Williamson Date: Fri, 15 May 2015 16:55:30 +0000 (-0600) Subject: utf8.h: Add assertions to macro X-Git-Tag: if-0.0605~83 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/635e76f560b3b3ca075aa2cb5d6d661601968e04?hp=5f560d8a4c59b10752c634d9aa60ea57dd4eeff1 utf8.h: Add assertions to macro --- diff --git a/utf8.h b/utf8.h index 2e1aa02..271796b 100644 --- a/utf8.h +++ b/utf8.h @@ -356,8 +356,10 @@ encoded as UTF-8. C is a native (ASCII or EBCDIC) code point if less than * Note that the result can be larger than 255 if the input character is not * downgradable */ #define TWO_BYTE_UTF8_TO_NATIVE(HI, LO) \ + ( __ASSERT_(UTF8SKIP(HI) == 2) \ + __ASSERT_(UTF8_IS_CONTINUATION(LO)) \ UNI_TO_NATIVE(UTF8_ACCUMULATE((NATIVE_UTF8_TO_I8(HI) & UTF_START_MASK(2)), \ - (LO))) + (LO)))) /* Should never be used, and be deprecated */ #define TWO_BYTE_UTF8_TO_UNI(HI, LO) NATIVE_TO_UNI(TWO_BYTE_UTF8_TO_NATIVE(HI, LO))