diff src/dmstring.c @ 2494:fcaf2db0cd05

Remove dm_str(n)casecmp() functions, in favour of standard libc ones.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 28 Apr 2020 20:34:49 +0300
parents 18ec4c092108
children
line wrap: on
line diff
--- a/src/dmstring.c	Tue Apr 28 20:28:35 2020 +0300
+++ b/src/dmstring.c	Tue Apr 28 20:34:49 2020 +0300
@@ -2,53 +2,6 @@
 #include <stdarg.h>
 
 
-/* Compare two strings ignoring case [strcasecmp, strncasecmp]
- */
-int dm_strcasecmp(const char *haystack, const char *needle)
-{
-    const char *s1 = haystack, *s2 = needle;
-    assert(haystack != NULL);
-    assert(needle != NULL);
-
-    if (haystack == needle)
-        return 0;
-
-    while (*s1 && *s2)
-    {
-        int k = tolower(*s1) - tolower(*s2);
-        if (k != 0)
-            return k;
-        s1++;
-        s2++;
-    }
-
-    return tolower(*s1) - tolower(*s2);
-}
-
-
-int dm_strncasecmp(const char *haystack, const char *needle, size_t n)
-{
-    const char *s1 = haystack, *s2 = needle;
-    assert(haystack != NULL);
-    assert(needle != NULL);
-
-    if (haystack == needle)
-        return 0;
-
-    while (n > 0 && *s1 && *s2)
-    {
-        int k = tolower(*s1) - tolower(*s2);
-        if (k != 0)
-            return k;
-        s1++;
-        s2++;
-        n--;
-    }
-
-    return (n == 0) ? 0 : tolower(*s1) - tolower(*s2);
-}
-
-
 /* Check if end of the given string str matches needle
  * case-insensitively, return pointer to start of the match,
  * if found, NULL otherwise.
@@ -66,7 +19,7 @@
         if (slen < nlen)
             return NULL;
 
-        if (dm_strcasecmp(str + slen - nlen, needle) == 0)
+        if (strcasecmp(str + slen - nlen, needle) == 0)
             return str + slen - nlen;
         else
             return NULL;