changeset 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 ec036e88a0c2
children 88c68a03c493
files src/dmlib.h src/dmstring.c tools/fanalyze.c tools/gfxconv.c
diffstat 4 files changed, 5 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmlib.h	Tue Apr 28 20:28:35 2020 +0300
+++ b/src/dmlib.h	Tue Apr 28 20:34:49 2020 +0300
@@ -459,8 +459,6 @@
 char *     dm_strdup_vprintf(const char *fmt, va_list args);
 char *     dm_strdup_printf(const char *fmt, ...);
 
-int        dm_strcasecmp(const char *haystack, const char *needle);
-int        dm_strncasecmp(const char *haystack, const char *needle, size_t n);
 char *     dm_strrcasecmp(char *str, const char *needle);
 
 BOOL       dmGetIntVal(const char *str, unsigned int *value, BOOL *neg);
--- 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;
--- a/tools/fanalyze.c	Tue Apr 28 20:28:35 2020 +0300
+++ b/tools/fanalyze.c	Tue Apr 28 20:34:49 2020 +0300
@@ -310,13 +310,13 @@
         char *vtmp = vspec;
 
         // Get endianess specifier, if any
-        if (dm_strncasecmp(vtmp, "le", 2) == 0)
+        if (strncasecmp(vtmp, "le", 2) == 0)
         {
             vendianess = TRUE;
             vtmp += 2;
         }
         else
-        if (dm_strncasecmp(vtmp, "be", 2) == 0)
+        if (strncasecmp(vtmp, "be", 2) == 0)
         {
             vendianess = FALSE;
             vtmp += 2;
--- a/tools/gfxconv.c	Tue Apr 28 20:28:35 2020 +0300
+++ b/tools/gfxconv.c	Tue Apr 28 20:34:49 2020 +0300
@@ -1065,7 +1065,7 @@
                     if (strcasecmp(topt, "alpha") == 0)
                         optRemapMatchAlpha = TRUE;
                     else
-                    if (dm_strncasecmp(topt, "max=", 4) == 0)
+                    if (strncasecmp(topt, "max=", 4) == 0)
                     {
                         char *start = topt + 4, *end;
                         optRemapMaxDist = strtof(start, &end);
@@ -1078,7 +1078,7 @@
                         }
                     }
                     else
-                    if (dm_strncasecmp(topt, "nomatch=", 8) == 0)
+                    if (strncasecmp(topt, "nomatch=", 8) == 0)
                     {
                         char *start = topt + 8, *end;
                         optRemapNoMatchColor = strtol(start, &end, 10);