This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Attempt at portability.
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 4 Mar 2002 13:34:15 +0000 (13:34 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Mon, 4 Mar 2002 13:34:15 +0000 (13:34 +0000)
p4raw-id: //depot/perl@14990

util.c

diff --git a/util.c b/util.c
index 4dc8676..3a23678 100644 (file)
--- a/util.c
+++ b/util.c
@@ -4366,16 +4366,20 @@ Perl_memcmp_byte_utf8(pTHX_ char *sb, STRLEN lbyte, char *su, STRLEN lutf)
     while (sbyte < ebyte) {
        if (sutf >= eutf)
            return 1;                   /* utf one shorter */
-       if (*sbyte < 128) {
+       if (NATIVE_IS_INVARIANT(*sbyte)) {
            if (*sbyte != *sutf)
                return *sbyte - *sutf;
            sbyte++; sutf++;    /* CONTINUE */
-       } else if ((*sutf & 0x3F) == (*sbyte >> 6)) { /* byte 0xFF: 0xC3 BF */
-           if ((sutf[1] & 0x3F) != (*sbyte & 0x3F))
-               return (*sbyte & 0x3F) - (*sutf & 0x3F);
+       } else if ((*sutf & UTF_CONTINUATION_MASK) ==
+                   (*sbyte >> UTF_ACCUMULATION_SHIFT)) {
+           if ((sutf[1] & UTF_CONTINUATION_MASK) !=
+                (*sbyte & UTF_CONTINUATION_MASK))
+               return (*sbyte & UTF_CONTINUATION_MASK) -
+                       (*sutf & UTF_CONTINUATION_MASK);
            sbyte++, sutf += 2; /* CONTINUE */
        } else
-           return (*sbyte >> 6) - (*sutf & 0x3F);
+           return (*sbyte >> UTF_ACCUMULATION_SHIFT) -
+                   (*sutf & UTF_CONTINUATION_MASK);
     }
     if (sutf >= eutf)
        return 0;