Commit 8134072a authored by Thomas Roessler's avatar Thomas Roessler

Fix ascii_*cmp functions. Problem noted by Brad Thompson.

parent d2f5b741
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment