This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Refactor a portion of to_utf8_case()
[perl5.git] / utf8.c
diff --git a/utf8.c b/utf8.c
index 5469a8e..3afa69c 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2419,16 +2419,23 @@ Perl_to_utf8_case(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp,
         }
     }
 
-    if (!len) { /* There was no mapping defined, which means that the code
-                   point maps to itself */
+    if (len) {
+        if (lenp) {
+            *lenp = len;
+        }
+        return valid_utf8_to_uvchr(ustrp, 0);
+    }
+
+    /* Here, there was no mapping defined, which means that the code point maps
+     * to itself.  Return the inputs */
         len = UTF8SKIP(p);
         Copy(p, ustrp, len, U8);
-    }
 
     if (lenp)
         *lenp = len;
 
-    return len ? valid_utf8_to_uvchr(ustrp, 0) : 0;
+    return uv0;
+
 }
 
 STATIC UV