11988Swnj /* 242166Sbostic * Copyright (c) 1989 The Regents of the University of California. 335096Sbostic * All rights reserved. 435096Sbostic * 5*42637Sbostic * %sccs.include.redist.c% 61988Swnj */ 71988Swnj 835096Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*42637Sbostic static char sccsid[] = "@(#)strncmp.c 5.5 (Berkeley) 06/01/90"; 1035096Sbostic #endif /* LIBC_SCCS and not lint */ 1135096Sbostic 1242166Sbostic #include <sys/stdc.h> 1342166Sbostic #include <string.h> 1442166Sbostic 1542166Sbostic int 1642166Sbostic strncmp(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