Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / string / strncasecmp_l.c
blobb15c6c5452a51bd618663bc3cc182a9a11edf737
1 /*
2 FUNCTION
3 <<strncasecmp_l>>---case-insensitive character string compare
5 INDEX
6 strncasecmp_l
8 SYNOPSIS
9 #include <strings.h>
10 int strncasecmp_l(const char *<[a]>, const char * <[b]>,
11 size_t <[length]>, locale_t <[locale]>);
13 DESCRIPTION
14 <<strncasecmp_l>> compares up to <[length]> characters
15 from the string at <[a]> to the string at <[b]> in a
16 case-insensitive manner.
18 if <[locale]> is LC_GLOBAL_LOCALE or not a valid locale object, the
19 behaviour is undefined.
21 RETURNS
23 If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after
24 both are converted to lowercase), <<strncasecmp_l>> returns a
25 number greater than zero. If the two strings are equivalent,
26 <<strncasecmp_l>> returns zero. If <<*<[a]>>> sorts
27 lexicographically before <<*<[b]>>>, <<strncasecmp_l>> returns a
28 number less than zero.
30 PORTABILITY
31 <<strncasecmp_l>> is POSIX-1.2008.
33 <<strncasecmp_l>> requires no supporting OS subroutines. It uses
34 tolower_l() from elsewhere in this library.
36 QUICKREF
37 strncasecmp_l
40 #include <strings.h>
41 #include <ctype.h>
43 int
44 strncasecmp_l (const char *s1, const char *s2, size_t n,
45 struct __locale_t *locale)
47 int d = 0;
48 for ( ; n != 0; n--)
50 const int c1 = tolower_l (*s1++, locale);
51 const int c2 = tolower_l (*s2++, locale);
52 if (((d = c1 - c2) != 0) || (c2 == '\0'))
53 break;
55 return d;