00001 /* 00002 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. 00003 * See the copyright notice in the ACK home directory, in the file "Copyright". 00004 */ 00005 /* $Id: strncmp.c 5628 2009-11-09 10:26:00Z thruby $ */ 00006 00007 #include <string.h> 00008 00009 int 00010 strncmp(register const char *s1, register const char *s2, register size_t n) 00011 { 00012 if (n) { 00013 do { 00014 if (*s1 != *s2++) 00015 break; 00016 if (*s1++ == '\0') 00017 return 0; 00018 } while (--n > 0); 00019 if (n > 0) { 00020 if (*s1 == '\0') return -1; 00021 if (*--s2 == '\0') return 1; 00022 return (unsigned char) *s1 - (unsigned char) *s2; 00023 } 00024 } 00025 return 0; 00026 }
1.5.8