undef IS_UTF8_CHAR() on EBCDIC
SADAHIRO Tomoyuki [Sat, 8 Oct 2005 09:59:00 +0000 (09:59 +0000)]
Message-Id: <20051008165752.348A.BQW10602@nifty.com>

p4raw-id: //depot/perl@25716

lib/utf8.t
utf8.c
utf8.h

index 70ef1e3..81ebc22 100644 (file)
@@ -37,7 +37,7 @@ no utf8; # Ironic, no?
 #
 #
 
-plan tests => 146;
+plan tests => 150;
 
 {
     # bug id 20001009.001
@@ -431,3 +431,11 @@ SKIP: {
                     qr/Undefined subroutine utf8::moo/, {stderr=>1},
                    "Check Carp is loaded for AUTOLOADing errors")
 }
+
+{
+    # failure of is_utf8_char() without NATIVE_TO_UTF on EBCDIC (0260..027F)
+    ok(utf8::valid(chr(0x250)), "0x250");
+    ok(utf8::valid(chr(0x260)), "0x260");
+    ok(utf8::valid(chr(0x270)), "0x270");
+    ok(utf8::valid(chr(0x280)), "0x280");
+}
diff --git a/utf8.c b/utf8.c
index 66642c5..8ea2d7a 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -209,6 +209,9 @@ S_is_utf8_char_slow(pTHX_ const U8 *s, const STRLEN len)
 
     slen = len - 1;
     s++;
+#ifdef EBCDIC
+    u = NATIVE_TO_UTF(u);
+#endif
     u &= UTF_START_MASK(len);
     uv  = u;
     ouv = uv;
diff --git a/utf8.h b/utf8.h
index c8bcb36..4599407 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -258,6 +258,9 @@ encoded character.
 #endif
 #define SHARP_S_SKIP 2
 
+#ifdef EBCDIC
+/* IS_UTF8_CHAR() is not ported to EBCDIC */
+#else
 #define IS_UTF8_CHAR_1(p)      \
        ((p)[0] <= 0x7F)
 #define IS_UTF8_CHAR_2(p)      \
@@ -329,3 +332,4 @@ encoded character.
 
 #define IS_UTF8_CHAR_FAST(n) ((n) <= 4)
 
+#endif /* IS_UTF8_CHAR() for UTF-8 */