blead 25801: Symbian batch of today
[p5sagit/p5-mst-13.2.git] / utf8.c
diff --git a/utf8.c b/utf8.c
index 2a88a45..743dea4 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;
@@ -240,7 +243,7 @@ will be returned if it is valid, otherwise 0.
 STRLEN
 Perl_is_utf8_char(pTHX_ const U8 *s)
 {
-    STRLEN len = UTF8SKIP(s);
+    const STRLEN len = UTF8SKIP(s);
 #ifdef IS_UTF8_CHAR
     if (IS_UTF8_CHAR_FAST(len))
         return IS_UTF8_CHAR(s, len) ? len : 0;
@@ -267,7 +270,7 @@ Perl_is_utf8_string(pTHX_ const U8 *s, STRLEN len)
     const U8* x = s;
     const U8* send;
 
-    if (!len && s)
+    if (!len)
        len = strlen((const char *)s);
     send = s + len;
 
@@ -323,7 +326,7 @@ Perl_is_utf8_string_loclen(pTHX_ const U8 *s, STRLEN len, const U8 **ep, STRLEN
     const U8* send;
     STRLEN c;
 
-    if (!len && s)
+    if (!len)
         len = strlen((const char *)s);
     send = s + len;
     if (el)
@@ -543,7 +546,7 @@ malformed:
     }
 
     if (dowarn) {
-       SV* sv = sv_2mortal(newSVpv("Malformed UTF-8 character ", 0));
+       SV* const sv = sv_2mortal(newSVpv("Malformed UTF-8 character ", 0));
 
        switch (warning) {
        case 0: /* Intentionally empty. */ break;
@@ -557,10 +560,12 @@ malformed:
            if (s == s0)
                Perl_sv_catpvf(aTHX_ sv, "(unexpected non-continuation byte 0x%02"UVxf", immediately after start byte 0x%02"UVxf")",
                            (UV)s[1], startbyte);
-           else
+           else {
+               const int len = (int)(s-s0);
                Perl_sv_catpvf(aTHX_ sv, "(unexpected non-continuation byte 0x%02"UVxf", %d byte%s after start byte 0x%02"UVxf", expected %d bytes)",
-                           (UV)s[1], s - s0, s - s0 > 1 ? "s" : "", startbyte, (int)expectlen);
-             
+                           (UV)s[1], len, len > 1 ? "s" : "", startbyte, (int)expectlen);
+           }
+
            break;
        case UTF8_WARN_FE_FF:
            Perl_sv_catpvf(aTHX_ sv, "(byte 0x%02"UVxf")", uv);
@@ -590,7 +595,7 @@ malformed:
        }
        
        if (warning) {
-           const char *s = SvPVX_const(sv);
+           const char * const s = SvPVX_const(sv);
 
            if (PL_op)
                Perl_warner(aTHX_ packWARN(WARN_UTF8),