fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / string / strncasecmp.c
blob28c6cc44f1312e6d85c59fe58b1979c579f6d73c
1 /*
2 FUNCTION
3 <<strncasecmp>>---case insensitive character string compare
5 INDEX
6 strncasecmp
8 ANSI_SYNOPSIS
9 #include <string.h>
10 int strncasecmp(const char *<[a]>, const char * <[b]>, size_t <[length]>);
12 TRAD_SYNOPSIS
13 #include <string.h>
14 int strncasecmp(<[a]>, <[b]>, <[length]>)
15 char *<[a]>;
16 char *<[b]>;
17 size_t <[length]>
19 DESCRIPTION
20 <<strncasecmp>> compares up to <[length]> characters
21 from the string at <[a]> to the string at <[b]> in a
22 case-insensitive manner.
24 RETURNS
26 If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after
27 both are converted to upper case), <<strncasecmp>> returns a
28 number greater than zero. If the two strings are equivalent,
29 <<strncasecmp>> returns zero. If <<*<[a]>>> sorts
30 lexicographically before <<*<[b]>>>, <<strncasecmp>> returns a
31 number less than zero.
33 PORTABILITY
34 <<strncasecmp>> is in the Berkeley Software Distribution.
36 <<strncasecmp>> requires no supporting OS subroutines. It uses
37 tolower() from elsewhere in this library.
39 QUICKREF
40 strncasecmp
43 #include <string.h>
44 #include <ctype.h>
46 int
47 _DEFUN (strncasecmp, (s1, s2, n),
48 _CONST char *s1 _AND
49 _CONST char *s2 _AND
50 size_t n)
52 if (n == 0)
53 return 0;
55 while (n-- != 0 && tolower(*s1) == tolower(*s2))
57 if (n == 0 || *s1 == '\0' || *s2 == '\0')
58 break;
59 s1++;
60 s2++;
63 return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);