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

int strncasecmp(const char *s, const char *t, size_t n) {
  register char x;
  register const char* u=s+n;
  for (;;) {
    x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t;
#ifndef WANT_SMALL_STRING_ROUTINES
    x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t;
    x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t;
    x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t;
#endif
  }
  return ((int)(unsigned int)(unsigned char) x)
       - ((int)(unsigned int)(unsigned char) *t);
}