scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

strncmp.c (243B)


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