shithub: scc

ref: 2b9e16f9e9a4f8b06d778d5de834a30ac96fbd53
dir: /lib/c/strncmp.c/

View raw version
#include <string.h>
#undef strncmp

int
strncmp(const char *s1, const char *s2, size_t n)
{
	int c;

	if (n == 0)
		return 0;
	while ((c = *s1) != '\0' && c == *s2) {
		if (--n == 0)
			return 0;
		++s1, ++s2;
	}
	return (*(unsigned char *) s1 - *(unsigned char *) s2);
}