11988Swnj /* 2*61193Sbostic * Copyright (c) 1989, 1993 3*61193Sbostic * The Regents of the University of California. All rights reserved. 435096Sbostic * 542637Sbostic * %sccs.include.redist.c% 61988Swnj */ 71988Swnj 835096Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*61193Sbostic static char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 06/04/93"; 1035096Sbostic #endif /* LIBC_SCCS and not lint */ 1135096Sbostic 1246144Sbostic #include <sys/cdefs.h> 1342166Sbostic #include <string.h> 1442166Sbostic 1542166Sbostic int strncmp(s1,s2,n)1642166Sbosticstrncmp(s1, s2, n) 1742166Sbostic register const char *s1, *s2; 1842166Sbostic register size_t n; 191988Swnj { 2042166Sbostic 2142166Sbostic if (n == 0) 2242166Sbostic return (0); 2342166Sbostic do { 2442166Sbostic if (*s1 != *s2++) 2542166Sbostic return (*(unsigned char *)s1 - *(unsigned char *)--s2); 2642166Sbostic if (*s1++ == 0) 2742166Sbostic break; 2842166Sbostic } while (--n != 0); 2942166Sbostic return (0); 301988Swnj } 31