wcscasecmp.c revision 189136
1189136Sdas/*- 2189136Sdas * Copyright (c) 2009 David Schultz <das@FreeBSD.org> 3189136Sdas * All rights reserved. 4189136Sdas * 5189136Sdas * Redistribution and use in source and binary forms, with or without 6189136Sdas * modification, are permitted provided that the following conditions 7189136Sdas * are met: 8189136Sdas * 1. Redistributions of source code must retain the above copyright 9189136Sdas * notice, this list of conditions and the following disclaimer. 10189136Sdas * 2. Redistributions in binary form must reproduce the above copyright 11189136Sdas * notice, this list of conditions and the following disclaimer in the 12189136Sdas * documentation and/or other materials provided with the distribution. 13189136Sdas * 14189136Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15189136Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16189136Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17189136Sdas * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18189136Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19189136Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20189136Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21189136Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22189136Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23189136Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24189136Sdas * SUCH DAMAGE. 25189136Sdas */ 26189136Sdas 27189136Sdas#include <sys/cdefs.h> 28189136Sdas__FBSDID("$FreeBSD: head/lib/libc/string/wcscasecmp.c 189136 2009-02-28 06:00:58Z das $"); 29189136Sdas 30189136Sdas#include <wchar.h> 31189136Sdas#include <wctype.h> 32189136Sdas 33189136Sdasint 34189136Sdaswcscasecmp(const wchar_t *s1, const wchar_t *s2) 35189136Sdas{ 36189136Sdas wchar_t c1, c2; 37189136Sdas 38189136Sdas for (; *s1; s1++, s2++) { 39189136Sdas c1 = towlower(*s1); 40189136Sdas c2 = towlower(*s2); 41189136Sdas if (c1 != c2) 42189136Sdas return ((int)c1 - c2); 43189136Sdas } 44189136Sdas return (-*s2); 45189136Sdas} 46