summaryrefslogtreecommitdiff
path: root/libc/string/strncasecmp.c
blob: a1bb15574e440a3f75861bca534a49adfa6baa19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
 * This file is part of the Linux-8086 C library and is distributed
 * under the GNU Library General Public License.
 */

#include <string.h>
#include <ctype.h>

int strncasecmp (const char *a, const char *b, size_t len)
{
    register int n;

    if (len < 1)
	return 0;
    while (*a == *b || (n = tolower (*a) - tolower (*b)) == 0)
    {
	if (*a == '\0' || --len < 1)
	    return 0;
	a++, b++;
    }
    return n;
}