FreeCalypso > hg > freecalypso-tools
comparison target-utils/libc/strncmp.c @ 87:7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 28 Oct 2016 22:20:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:684eddecbc62 | 87:7fb62fc724dc |
---|---|
1 /* | |
2 * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0 | |
3 */ | |
4 | |
5 strncmp(s1, s2, n) | |
6 register char *s1, *s2; | |
7 register n; | |
8 { | |
9 while (--n >= 0 && *s1 == *s2++) | |
10 if (*s1++ == '\0') | |
11 return(0); | |
12 return(n<0 ? 0 : *s1 - *--s2); | |
13 } |