summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/strncmp.c
blob: b3b56cfbb337c4c87f1cdaa0ae243557114f07a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <sys/types.h>
#include <string.h>

/* gcc is broken and has a non-SUSv2 compliant internal prototype.
 * This causes it to warn about a type mismatch here.  Ignore it. */
int strncmp(const char *s1, const char *s2, size_t n) {
  register const char* a=s1;
  register const char* b=s2;
  register const char* fini=a+n;
  while (a<fini) {
    register int res=*a-*b;
    if (res) return res;
    if (!*a) return 0;
    ++a; ++b;
  }
  return 0;
}