blob: e984e723c73b144a71967d3e56d6f9eb3b3b7e9d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/***
*wcsnicmp.c - compare first n characters of two wide character strings with
* case insensitivity
*
* Copyright (c) 1985-1988, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines wcsnicmp() - compare first n characters of two wide character
* strings for lexical order with case insensitivity.
*
*Revision History:
* 04-07-91 IanJa C version created.
* 11-25-91 AlexT Modified from wcsncmp.c
* 04-Mar-92 ChrisMay fixed signed/unsigned warning in wcUP()
* 12-Mar-92 Fixed bug in wcsnicmp (used to return *first - *last)
*
*******************************************************************************/
#include <stdlib.h>
/***
*wchar_t wcUp(wc) - upper case wide character
*
*/
#define wcUp(wc) (('a' <= (wchar_t) (wc) && (wchar_t) (wc) <= 'z') ? \
(wchar_t) (wc) + (wchar_t)('A' - 'a') : (wchar_t) (wc))
/***
*int wcsnicmp(first, last, count) - compare first count wide characters of wide
* character strings with case insensitivity.
*
*Purpose:
* Compares two wide character strings for lexical order. The comparison
* stops after: (1) a difference between the strings is found, (2) the end
* of the strings is reached, or (3) count characters have been
* compared.
*
*Entry:
* char *first, *last - wide character strings to compare
* unsigned count - maximum number of wide characters to compare
*
*Exit:
* returns <0 if first < last
* returns 0 if first == last
* returns >0 if first > last
*
*Exceptions:
*
*******************************************************************************/
int _CRTAPI1 wcsnicmp(const wchar_t * first, const wchar_t * last, size_t count)
{
if (!count)
return 0;
while (--count && *first && wcUp(*first) == wcUp(*last))
{
first++;
last++;
}
return wcUp(*first) - wcUp(*last);
}
|