176612Stshiozak/*
276612Stshiozak * Copyright (c) 1989, 1993
376612Stshiozak *	The Regents of the University of California.  All rights reserved.
476612Stshiozak *
576612Stshiozak * Redistribution and use in source and binary forms, with or without
676612Stshiozak * modification, are permitted provided that the following conditions
776612Stshiozak * are met:
876612Stshiozak * 1. Redistributions of source code must retain the above copyright
976612Stshiozak *    notice, this list of conditions and the following disclaimer.
1076612Stshiozak * 2. Redistributions in binary form must reproduce the above copyright
1176612Stshiozak *    notice, this list of conditions and the following disclaimer in the
1276612Stshiozak *    documentation and/or other materials provided with the distribution.
1376612Stshiozak * 4. Neither the name of the University nor the names of its contributors
1476612Stshiozak *    may be used to endorse or promote products derived from this software
1576612Stshiozak *    without specific prior written permission.
1676612Stshiozak *
1776612Stshiozak * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1876612Stshiozak * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1976612Stshiozak * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2076612Stshiozak * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2176612Stshiozak * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2276612Stshiozak * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2376612Stshiozak * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2476612Stshiozak * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2576612Stshiozak * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2676612Stshiozak * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2776612Stshiozak * SUCH DAMAGE.
2876612Stshiozak */
2976612Stshiozak
3076612Stshiozak#include <sys/cdefs.h>
3192986Sobrien#if 0
3276612Stshiozak#if defined(LIBC_SCCS) && !defined(lint)
3376612Stshiozakstatic char sccsid[] = "@(#)strncmp.c	8.1 (Berkeley) 6/4/93";
34105787Stjr__RCSID("$NetBSD: wcsncmp.c,v 1.3 2001/01/05 12:13:13 itojun Exp $");
3576612Stshiozak#endif /* LIBC_SCCS and not lint */
3692986Sobrien#endif
3786170Sobrien__FBSDID("$FreeBSD$");
3876612Stshiozak
3976612Stshiozak#include <wchar.h>
4076612Stshiozak
4176612Stshiozakint
42188080Sdangerwcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
4376612Stshiozak{
4476612Stshiozak
4576612Stshiozak	if (n == 0)
4676612Stshiozak		return (0);
4776612Stshiozak	do {
4876612Stshiozak		if (*s1 != *s2++) {
4976612Stshiozak			/* XXX assumes wchar_t = int */
5076612Stshiozak			return (*(const unsigned int *)s1 -
5176612Stshiozak			    *(const unsigned int *)--s2);
5276612Stshiozak		}
5376612Stshiozak		if (*s1++ == 0)
5476612Stshiozak			break;
5576612Stshiozak	} while (--n != 0);
5676612Stshiozak	return (0);
5776612Stshiozak}
58