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