scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

strncmp.c (231B)


      1 #include <string.h>
      2 #undef strncmp
      3 
      4 int
      5 strncmp(const char *s1, const char *s2, size_t n)
      6 {
      7 	for (; n && *s1 && *s2 && *s1 == *s2; --n, ++s1, ++s2);
      8 		/* nothing */;
      9 	return n ? (*(unsigned char *)s1 - *(unsigned char *)s2) : 0;
     10 }