From: Thomas Roessler Date: Tue, 5 Feb 2002 10:51:51 +0000 (+0000) Subject: Fix ascii_*cmp functions. Problem noted by Brad Thompson. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39bf7685b0a4edd4b7883537b9e85536f987bdcc;p=neomutt Fix ascii_*cmp functions. Problem noted by Brad Thompson. --- diff --git a/ascii.c b/ascii.c index d4553f683..59dfb440d 100644 --- a/ascii.c +++ b/ascii.c @@ -67,13 +67,13 @@ int ascii_strcasecmp (const char *a, const char *b) if (b == NULL && a) return 1; - for (; *a || *b; a++, b++) + for (; *a && *b; a++, b++) { if ((i = ascii_tolower (*a) - ascii_tolower (*b))) return i; } - - return 0; + + return ascii_tolower (*a) - ascii_tolower (*b); } int ascii_strncasecmp (const char *a, const char *b, int n) @@ -87,11 +87,13 @@ int ascii_strncasecmp (const char *a, const char *b, int n) if (b == NULL && a) return 1; - for (j = 0; (*a || *b) && j < n; a++, b++, j++) + for (j = 0; (*a && *b) && j < n; a++, b++, j++) { if ((i = ascii_tolower (*a) - ascii_tolower (*b))) return i; } - - return 0; + if (j < n) + return ascii_tolower (*a) - ascii_tolower (*b); + else + return 0; }