about summary refs log tree commit diff
path: root/src/string/strncmp.c
blob: 52ba032324a3bea7cb22e93a76295111d3a1d49e (plain) (blame)
1
2
3
4
5
6
7
8
9
#include <string.h>

int strncmp(const char *_l, const char *_r, size_t n)
{
	const unsigned char *l=_l, *r=_r;
	if (!n--) return 0;
	for (; *l && *r && n && *l == *r ; l++, r++, n--);
	return *l - *r;
}