added strcasecmp() and strcasencmp()
[unix-history] / usr / src / lib / libc / string / strncmp.c
CommitLineData
2ce81398
DS
1#if defined(LIBC_SCCS) && !defined(lint)
2static char sccsid[] = "@(#)strncmp.c 5.2 (Berkeley) %G%";
3#endif LIBC_SCCS and not lint
b8f253e8 4
7db9433a
BJ
5/*
6 * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0
7 */
8
9strncmp(s1, s2, n)
10register char *s1, *s2;
11register n;
12{
13
14 while (--n >= 0 && *s1 == *s2++)
15 if (*s1++ == '\0')
16 return(0);
17 return(n<0 ? 0 : *s1 - *--s2);
18}