1*38a75b98Sguenther /* $OpenBSD: wcscmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */
2b689ee27Sespie /* $NetBSD: wcscmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */
3b689ee27Sespie
4b689ee27Sespie /*-
5b689ee27Sespie * Copyright (c) 1990, 1993
6b689ee27Sespie * The Regents of the University of California. All rights reserved.
7b689ee27Sespie *
8b689ee27Sespie * This code is derived from software contributed to Berkeley by
9b689ee27Sespie * Chris Torek.
10b689ee27Sespie *
11b689ee27Sespie * Redistribution and use in source and binary forms, with or without
12b689ee27Sespie * modification, are permitted provided that the following conditions
13b689ee27Sespie * are met:
14b689ee27Sespie * 1. Redistributions of source code must retain the above copyright
15b689ee27Sespie * notice, this list of conditions and the following disclaimer.
16b689ee27Sespie * 2. Redistributions in binary form must reproduce the above copyright
17b689ee27Sespie * notice, this list of conditions and the following disclaimer in the
18b689ee27Sespie * documentation and/or other materials provided with the distribution.
19b689ee27Sespie * 3. Neither the name of the University nor the names of its contributors
20b689ee27Sespie * may be used to endorse or promote products derived from this software
21b689ee27Sespie * without specific prior written permission.
22b689ee27Sespie *
23b689ee27Sespie * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24b689ee27Sespie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25b689ee27Sespie * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26b689ee27Sespie * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27b689ee27Sespie * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28b689ee27Sespie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29b689ee27Sespie * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30b689ee27Sespie * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31b689ee27Sespie * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32b689ee27Sespie * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33b689ee27Sespie * SUCH DAMAGE.
34b689ee27Sespie */
35b689ee27Sespie
36b689ee27Sespie #include <wchar.h>
37b689ee27Sespie #include "locale/runetype.h"
38b689ee27Sespie
39b689ee27Sespie /*
40b689ee27Sespie * Compare strings.
41b689ee27Sespie */
42b689ee27Sespie int
wcscmp(const wchar_t * s1,const wchar_t * s2)431c031cf6Sespie wcscmp(const wchar_t *s1, const wchar_t *s2)
44b689ee27Sespie {
45b689ee27Sespie
46b689ee27Sespie while (*s1 == *s2++)
47b689ee27Sespie if (*s1++ == 0)
48b689ee27Sespie return (0);
49b689ee27Sespie /* XXX assumes wchar_t = int */
5089b0597fSespie return (*(const rune_t *)s1 - *(const rune_t *)--s2);
51b689ee27Sespie }
52*38a75b98Sguenther DEF_STRONG(wcscmp);
53