source: trunk/sys/dietlibc/strncmp.c @ 21

Last change on this file since 21 was 1, checked in by alain, 8 years ago

First import

File size: 502 bytes
Line 
1#include <string.h>
2
3/* gcc is broken and has a non-SUSv2 compliant internal prototype.
4 * This causes it to warn about a type mismatch here.  Ignore it. */
5int strncmp(const char *s1, const char *s2, size_t n) {
6  register const unsigned char* a=(const unsigned char*)s1;
7  register const unsigned char* b=(const unsigned char*)s2;
8  register const unsigned char* fini=a+n;
9  while (a<fini) {
10    register int res=*a-*b;
11    if (res) return res;
12    if (!*a) return 0;
13    ++a; ++b;
14  }
15  return 0;
16}
Note: See TracBrowser for help on using the repository browser.