This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: Avoid hard-coded utf8 tests for EBCDIC
authorKarl Williamson <public@khwilliamson.com>
Mon, 26 Sep 2011 19:24:08 +0000 (13:24 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sat, 1 Oct 2011 15:15:32 +0000 (09:15 -0600)
When a swash is loaded, generally it is checked for sanity with an
assert().  The strings used are hard-coded utf8 strings, which will be
different in EBCDIC, and hence will fail.  I haven't figured out a
simple way to get compile-time utf8 vs utfebcdic strings, but we can
just skip the check in EBCDIC builds

regexec.c

index e6d3fa4..1aa6129 100644 (file)
--- a/regexec.c
+++ b/regexec.c
 #define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
 
 /* these are unrolled below in the CCC_TRY_XXX defined */
 #define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
 
 /* these are unrolled below in the CCC_TRY_XXX defined */
-#define LOAD_UTF8_CHARCLASS(class,str) STMT_START { \
+#ifdef EBCDIC
+    /* Often 'str' is a hard-coded utf8 string instead of utfebcdic. so just
+     * skip the check on EBCDIC platforms */
+#   define LOAD_UTF8_CHARCLASS(class,str) LOAD_UTF8_CHARCLASS_NO_CHECK(class)
+#else
+#   define LOAD_UTF8_CHARCLASS(class,str) STMT_START { \
     if (!CAT2(PL_utf8_,class)) { \
        bool ok; \
        ENTER; save_re_context(); \
        ok=CAT2(is_utf8_,class)((const U8*)str); \
        assert(ok); assert(CAT2(PL_utf8_,class)); LEAVE; } } STMT_END
     if (!CAT2(PL_utf8_,class)) { \
        bool ok; \
        ENTER; save_re_context(); \
        ok=CAT2(is_utf8_,class)((const U8*)str); \
        assert(ok); assert(CAT2(PL_utf8_,class)); LEAVE; } } STMT_END
+#endif
 
 /* Doesn't do an assert to verify that is correct */
 #define LOAD_UTF8_CHARCLASS_NO_CHECK(class) STMT_START { \
 
 /* Doesn't do an assert to verify that is correct */
 #define LOAD_UTF8_CHARCLASS_NO_CHECK(class) STMT_START { \