1a231d5c7SJohn Marino /*-
2a231d5c7SJohn Marino * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
3a231d5c7SJohn Marino * All rights reserved.
4a231d5c7SJohn Marino *
5a231d5c7SJohn Marino * Redistribution and use in source and binary forms, with or without
6a231d5c7SJohn Marino * modification, are permitted provided that the following conditions
7a231d5c7SJohn Marino * are met:
8a231d5c7SJohn Marino * 1. Redistributions of source code must retain the above copyright
9a231d5c7SJohn Marino * notice, this list of conditions and the following disclaimer.
10a231d5c7SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright
11a231d5c7SJohn Marino * notice, this list of conditions and the following disclaimer in the
12a231d5c7SJohn Marino * documentation and/or other materials provided with the distribution.
13a231d5c7SJohn Marino *
14a231d5c7SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15a231d5c7SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16a231d5c7SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17a231d5c7SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18a231d5c7SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19a231d5c7SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20a231d5c7SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21a231d5c7SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22a231d5c7SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23a231d5c7SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24a231d5c7SJohn Marino * SUCH DAMAGE.
25*0d5acd74SJohn Marino *
26*0d5acd74SJohn Marino * $FreeBSD: head/lib/libc/string/wcscasecmp.c 189136 2009-02-28 06:00:58Z das $
27a231d5c7SJohn Marino */
28a231d5c7SJohn Marino
29a231d5c7SJohn Marino #include <wchar.h>
30a231d5c7SJohn Marino #include <wctype.h>
31a231d5c7SJohn Marino
32a231d5c7SJohn Marino int
wcscasecmp(const wchar_t * s1,const wchar_t * s2)33a231d5c7SJohn Marino wcscasecmp(const wchar_t *s1, const wchar_t *s2)
34a231d5c7SJohn Marino {
35a231d5c7SJohn Marino wchar_t c1, c2;
36a231d5c7SJohn Marino
37a231d5c7SJohn Marino for (; *s1; s1++, s2++) {
38a231d5c7SJohn Marino c1 = towlower(*s1);
39a231d5c7SJohn Marino c2 = towlower(*s2);
40a231d5c7SJohn Marino if (c1 != c2)
41a231d5c7SJohn Marino return ((int)c1 - c2);
42a231d5c7SJohn Marino }
43a231d5c7SJohn Marino return (-*s2);
44a231d5c7SJohn Marino }
45