wcsncmp.c revision 86170
1132718Skan/* 250397Sobrien * Copyright (c) 1989, 1993 3132718Skan * The Regents of the University of California. All rights reserved. 4132718Skan * 550397Sobrien * Redistribution and use in source and binary forms, with or without 6132718Skan * modification, are permitted provided that the following conditions 750397Sobrien * are met: 8132718Skan * 1. Redistributions of source code must retain the above copyright 9132718Skan * notice, this list of conditions and the following disclaimer. 10132718Skan * 2. Redistributions in binary form must reproduce the above copyright 11132718Skan * notice, this list of conditions and the following disclaimer in the 1250397Sobrien * documentation and/or other materials provided with the distribution. 13132718Skan * 3. All advertising materials mentioning features or use of this software 14132718Skan * must display the following acknowledgement: 15132718Skan * This product includes software developed by the University of 16132718Skan * California, Berkeley and its contributors. 1750397Sobrien * 4. Neither the name of the University nor the names of its contributors 1850397Sobrien * may be used to endorse or promote products derived from this software 19132718Skan * without specific prior written permission. 20169689Skan * 21169689Skan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2250397Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2390075Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2450397Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2550397Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2650397Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27132718Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28132718Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29132718Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30169689Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31169689Skan * SUCH DAMAGE. 32169689Skan */ 33169689Skan 34169689Skan#include <sys/cdefs.h> 35169689Skan#if defined(LIBC_SCCS) && !defined(lint) 36169689Skanstatic char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 6/4/93"; 37__RCSID("$NetBSD$"); 38#endif /* LIBC_SCCS and not lint */ 39__FBSDID("$FreeBSD: head/lib/libc/string/wcsncmp.c 86170 2001-11-07 19:55:16Z obrien $"); 40 41#include <assert.h> 42#include <wchar.h> 43 44int 45wcsncmp(s1, s2, n) 46 const wchar_t *s1, *s2; 47 size_t n; 48{ 49 50 if (n == 0) 51 return (0); 52 do { 53 if (*s1 != *s2++) { 54 /* XXX assumes wchar_t = int */ 55 return (*(const unsigned int *)s1 - 56 *(const unsigned int *)--s2); 57 } 58 if (*s1++ == 0) 59 break; 60 } while (--n != 0); 61 return (0); 62} 63