source: trunk/libs/newlib/src/newlib/libc/string/wcsncasecmp.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.1 KB
Line 
1/*
2FUNCTION
3        <<wcsncasecmp>>---case-insensitive wide character string compare
4       
5INDEX
6        wcsncasecmp
7
8SYNOPSIS
9        #include <wchar.h>
10        int wcsncasecmp(const wchar_t *<[a]>, const wchar_t * <[b]>, size_t <[length]>);
11
12DESCRIPTION
13        <<wcsncasecmp>> compares up to <[length]> wide characters
14        from the string at <[a]> to the string at <[b]> in a
15        case-insensitive manner.
16
17RETURNS
18
19        If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after
20        both are converted to uppercase), <<wcsncasecmp>> returns a
21        number greater than zero.  If the two strings are equivalent,
22        <<wcsncasecmp>> returns zero.  If <<*<[a]>>> sorts
23        lexicographically before <<*<[b]>>>, <<wcsncasecmp>> returns a
24        number less than zero.
25
26PORTABILITY
27POSIX-1.2008
28
29<<wcsncasecmp>> requires no supporting OS subroutines. It uses
30tolower() from elsewhere in this library.
31
32QUICKREF
33        wcsncasecmp
34*/
35
36#include <wchar.h>
37#include <wctype.h>
38
39int 
40wcsncasecmp (const wchar_t *s1,
41        const wchar_t *s2,
42        size_t n)
43{
44  int d = 0;
45  for ( ; n != 0; n--)
46    {
47      const int c1 = towlower (*s1++);
48      const int c2 = towlower (*s2++);
49      if (((d = c1 - c2) != 0) || (c2 == '\0'))
50        break;
51    }
52  return d;
53}
Note: See TracBrowser for help on using the repository browser.