OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [string/] [wcsncasecmp.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
FUNCTION
3
        <<wcsncasecmp>>---case-insensitive wide character string compare
4
 
5
INDEX
6
        wcsncasecmp
7
 
8
ANSI_SYNOPSIS
9
        #include <wchar.h>
10
        int wcsncasecmp(const wchar_t *<[a]>, const wchar_t * <[b]>, size_t <[length]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <wchar.h>
14
        int wcsncasecmp(<[a]>, <[b]>, <[length]>)
15
        wchar_t *<[a]>;
16
        wchar_t *<[b]>;
17
        size_t <[length]>
18
 
19
DESCRIPTION
20
        <<wcsncasecmp>> compares up to <[length]> wide characters
21
        from the string at <[a]> to the string at <[b]> in a
22
        case-insensitive manner.
23
 
24
RETURNS
25
 
26
        If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after
27
        both are converted to uppercase), <<wcsncasecmp>> returns a
28
        number greater than zero.  If the two strings are equivalent,
29
        <<wcsncasecmp>> returns zero.  If <<*<[a]>>> sorts
30
        lexicographically before <<*<[b]>>>, <<wcsncasecmp>> returns a
31
        number less than zero.
32
 
33
PORTABILITY
34
POSIX-1.2008
35
 
36
<<wcsncasecmp>> requires no supporting OS subroutines. It uses
37
tolower() from elsewhere in this library.
38
 
39
QUICKREF
40
        wcsncasecmp
41
*/
42
 
43
#include <wchar.h>
44
#include <wctype.h>
45
 
46
int
47
_DEFUN (wcsncasecmp, (s1, s2, n),
48
        _CONST wchar_t *s1 _AND
49
        _CONST wchar_t *s2 _AND
50
        size_t n)
51
{
52
  if (n == 0)
53
    return 0;
54
 
55
  while (n-- != 0 && towlower(*s1) == towlower(*s2))
56
    {
57
      if (n == 0 || *s1 == '\0' || *s2 == '\0')
58
        break;
59
      s1++;
60
      s2++;
61
    }
62
 
63
  return towlower(*s1) - towlower(*s2);
64
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.