changeset 2465:63dd0a611586

Sync string handling fixes from th-libs.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Apr 2020 14:07:38 +0300
parents 7722c150d6de
children 213ce6d400dc
files src/dmstring.c
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmstring.c	Thu Apr 16 10:36:45 2020 +0300
+++ b/src/dmstring.c	Thu Apr 16 14:07:38 2020 +0300
@@ -22,7 +22,7 @@
         s2++;
     }
 
-    return 0;
+    return tolower(*s1) - tolower(*s2);
 }
 
 
@@ -45,7 +45,7 @@
         n--;
     }
 
-    return 0;
+    return tolower(*s1) - tolower(*s2);
 }
 
 
@@ -57,18 +57,20 @@
 {
     if (str == NULL || needle == NULL)
         return NULL;
-
-    const size_t
-        slen = strlen(str),
-        nlen = strlen(needle);
+    else
+    {
+        const size_t
+            slen = strlen(str),
+            nlen = strlen(needle);
 
-    if (slen < nlen)
-        return NULL;
+        if (slen < nlen)
+            return NULL;
 
-    if (dm_strcasecmp(str + slen - nlen, needle) == 0)
-        return str + slen - nlen;
-    else
-        return NULL;
+        if (dm_strcasecmp(str + slen - nlen, needle) == 0)
+            return str + slen - nlen;
+        else
+            return NULL;
+    }
 }