src/physfs_unicode.c
changeset 1321 6929d3c0a347
parent 1255 f15ec4962d08
child 1351 ea662d0cbcf0
--- a/src/physfs_unicode.c	Tue Nov 27 00:12:39 2012 -0500
+++ b/src/physfs_unicode.c	Wed Nov 28 01:30:29 2012 -0500
@@ -449,9 +449,21 @@
     PHYSFS_uint32 folded1[3], folded2[3];
     locate_case_fold_mapping(cp1, folded1);
     locate_case_fold_mapping(cp2, folded2);
-    return ( (folded1[0] == folded2[0]) &&
-             (folded1[1] == folded2[1]) &&
-             (folded1[2] == folded2[2]) );
+
+    if (folded1[0] < folded2[0])
+        return -1;
+    else if (folded1[0] > folded2[0])
+        return 1;
+    else if (folded1[1] < folded2[1])
+        return -1;
+    else if (folded1[1] > folded2[1])
+        return 1;
+    else if (folded1[2] < folded2[2])
+        return -1;
+    else if (folded1[2] > folded2[2])
+        return 1;
+
+    return 0;  /* complete match. */
 } /* utf8codepointcmp */
 
 
@@ -461,8 +473,11 @@
     {
         const PHYSFS_uint32 cp1 = utf8codepoint(&str1);
         const PHYSFS_uint32 cp2 = utf8codepoint(&str2);
-        if (!utf8codepointcmp(cp1, cp2)) break;
-        if (cp1 == 0) return 1;
+        const int rc = utf8codepointcmp(cp1, cp2);
+        if (rc != 0)
+            return rc;
+        else if (cp1 == 0)
+            break;  /* complete match. */
     } /* while */
 
     return 0;
@@ -475,12 +490,15 @@
     {
         const PHYSFS_uint32 cp1 = utf8codepoint(&str1);
         const PHYSFS_uint32 cp2 = utf8codepoint(&str2);
-        if (!utf8codepointcmp(cp1, cp2)) return 0;
-        if (cp1 == 0) return 1;
+        const int rc = utf8codepointcmp(cp1, cp2);
+        if (rc != 0)
+            return rc;
+        else if (cp1 == 0)
+            return 0;
         n--;
     } /* while */
 
-    return 1;  /* matched to n chars. */
+    return 0;  /* matched to n chars. */
 } /* __PHYSFS_utf8strnicmp */