=cut
*/
-# define NATIVE_TO_LATIN1(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) ((ch) | 0)))
-# define LATIN1_TO_NATIVE(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) ((ch) | 0)))
+#define NATIVE_TO_LATIN1(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) (ch)))
+#define LATIN1_TO_NATIVE(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) (ch)))
/* I8 is an intermediate version of UTF-8 used only in UTF-EBCDIC. We thus
* consider it to be identical to UTF-8 on ASCII platforms. Strictly speaking
* because they are 8-bit encodings that serve the same purpose in Perl, and
* rarely do we need to distinguish them. The term "NATIVE_UTF8" applies to
* whichever one is applicable on the current platform */
-# define NATIVE_UTF8_TO_I8(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) ((ch) | 0)))
-# define I8_TO_NATIVE_UTF8(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) ((ch) | 0)))
+#define NATIVE_UTF8_TO_I8(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) (ch)))
+#define I8_TO_NATIVE_UTF8(ch) (__ASSERT_(FITS_IN_8_BITS(ch)) ((U8) (ch)))
-# define UNI_TO_NATIVE(ch) ((UV) ((ch) | 0))
-# define NATIVE_TO_UNI(ch) ((UV) ((ch) | 0))
+#define UNI_TO_NATIVE(ch) ((UV) ASSERT_NOT_PTR(ch))
+#define NATIVE_TO_UNI(ch) ((UV) ASSERT_NOT_PTR(ch))
/*
=cut
*/
-#define UTF8SKIP(s) PL_utf8skip[*(const U8*)(s)]
+#define UTF8SKIP(s) PL_utf8skip[*(const U8*)(ASSERT_IS_PTR(s))]
/*
=for apidoc Am|STRLEN|UTF8_SKIP|char* s
that it returns TRUE in each for the exact same set of bit patterns. It is
valid on a subset of what UVCHR_IS_INVARIANT is valid on, so can just use that;
and the compiler should optimize out anything extraneous given the
-implementation of the latter. The |0 makes sure this isn't mistakenly called
-with a ptr argument.
-*/
-#define UTF8_IS_INVARIANT(c) UVCHR_IS_INVARIANT((c) | 0)
+implementation of the latter. */
+#define UTF8_IS_INVARIANT(c) UVCHR_IS_INVARIANT(ASSERT_NOT_PTR(c))
/* Like the above, but its name implies a non-UTF8 input, which as the comments
* above show, doesn't matter as to its implementation */
*/
#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)) >= ((SSize_t)(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