1264377Sdes/*-
2264377Sdes * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
3264377Sdes * All rights reserved.
4264377Sdes *
5264377Sdes * Redistribution and use in source and binary forms, with or without
6264377Sdes * modification, are permitted provided that the following conditions
7264377Sdes * are met:
8264377Sdes * 1. Redistributions of source code must retain the above copyright
9264377Sdes *    notice, this list of conditions and the following disclaimer.
10264377Sdes * 2. Redistributions in binary form must reproduce the above copyright
11264377Sdes *    notice, this list of conditions and the following disclaimer in the
12264377Sdes *    documentation and/or other materials provided with the distribution.
13264377Sdes *
14264377Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15264377Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16264377Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17264377Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18264377Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19264377Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20264377Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21264377Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22264377Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23264377Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24264377Sdes * SUCH DAMAGE.
25264377Sdes */
26264377Sdes
27264377Sdes#include <sys/cdefs.h>
28264377Sdes__FBSDID("$FreeBSD$");
29264377Sdes
30264377Sdes#include <wchar.h>
31264377Sdes#include <wctype.h>
32264377Sdes
33264377Sdesint
34264377Sdeswcscasecmp(const wchar_t *s1, const wchar_t *s2)
35264377Sdes{
36264377Sdes	wchar_t c1, c2;
37264377Sdes
38264377Sdes	for (; *s1; s1++, s2++) {
39264377Sdes		c1 = towlower(*s1);
40264377Sdes		c2 = towlower(*s2);
41264377Sdes		if (c1 != c2)
42264377Sdes			return ((int)c1 - c2);
43264377Sdes	}
44264377Sdes	return (-*s2);
45264377Sdes}
46264377Sdes