src/string.c

changeset 1071
028cb6d22197
parent 1063
e453e717876e
child 1073
13c8a92625d4
--- a/src/string.c	Wed Jan 01 14:03:49 2025 +0100
+++ b/src/string.c	Wed Jan 01 15:26:50 2025 +0100
@@ -463,8 +463,10 @@
         cxstring s1,
         cxstring s2
 ) {
+    int r = strncmp(s1.ptr, s2.ptr, s1.length);
+    if (r != 0) return r;
     if (s1.length == s2.length) {
-        return memcmp(s1.ptr, s2.ptr, s1.length);
+        return 0;
     } else if (s1.length > s2.length) {
         return 1;
     } else {
@@ -476,12 +478,14 @@
         cxstring s1,
         cxstring s2
 ) {
+#ifdef _WIN32
+    int r = _strnicmp(s1.ptr, s2.ptr, s1.length);
+#else
+    int r = strncasecmp(s1.ptr, s2.ptr, s1.length);
+#endif
+    if (r != 0) return r;
     if (s1.length == s2.length) {
-#ifdef _WIN32
-        return _strnicmp(s1.ptr, s2.ptr, s1.length);
-#else
-        return strncasecmp(s1.ptr, s2.ptr, s1.length);
-#endif
+        return 0;
     } else if (s1.length > s2.length) {
         return 1;
     } else {

mercurial