wcsrchr.c revision 76612
176612Stshiozak/* $NetBSD: wcsrchr.c,v 1.1 2000/12/23 23:14:37 itojun Exp $ */ 276612Stshiozak 376612Stshiozak/*- 476612Stshiozak * Copyright (c)1999 Citrus Project, 576612Stshiozak * All rights reserved. 676612Stshiozak * 776612Stshiozak * Redistribution and use in source and binary forms, with or without 876612Stshiozak * modification, are permitted provided that the following conditions 976612Stshiozak * are met: 1076612Stshiozak * 1. Redistributions of source code must retain the above copyright 1176612Stshiozak * notice, this list of conditions and the following disclaimer. 1276612Stshiozak * 2. Redistributions in binary form must reproduce the above copyright 1376612Stshiozak * notice, this list of conditions and the following disclaimer in the 1476612Stshiozak * documentation and/or other materials provided with the distribution. 1576612Stshiozak * 1676612Stshiozak * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1776612Stshiozak * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1876612Stshiozak * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1976612Stshiozak * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2076612Stshiozak * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2176612Stshiozak * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2276612Stshiozak * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2376612Stshiozak * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2476612Stshiozak * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2576612Stshiozak * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2676612Stshiozak * SUCH DAMAGE. 2776612Stshiozak * 2876612Stshiozak * citrus Id: wcsrchr.c,v 1.2 2000/12/21 05:07:25 itojun Exp 2976612Stshiozak * 3076612Stshiozak * $FreeBSD: head/lib/libc/string/wcsrchr.c 76612 2001-05-15 06:01:19Z tshiozak $ 3176612Stshiozak */ 3276612Stshiozak 3376612Stshiozak#include <sys/cdefs.h> 3476612Stshiozak#if defined(LIBC_SCCS) && !defined(lint) 3576612Stshiozak__RCSID("$NetBSD: wcsrchr.c,v 1.1 2000/12/23 23:14:37 itojun Exp $"); 3676612Stshiozak#endif /* LIBC_SCCS and not lint */ 3776612Stshiozak 3876612Stshiozak#include <assert.h> 3976612Stshiozak#include <wchar.h> 4076612Stshiozak 4176612Stshiozakwchar_t * 4276612Stshiozakwcsrchr(s, c) 4376612Stshiozak const wchar_t *s; 4476612Stshiozak wchar_t c; 4576612Stshiozak{ 4676612Stshiozak const wchar_t *p; 4776612Stshiozak 4876612Stshiozak _DIAGASSERT(s != NULL); 4976612Stshiozak 5076612Stshiozak p = s; 5176612Stshiozak while (*p) 5276612Stshiozak p++; 5376612Stshiozak while (s <= p) { 5476612Stshiozak if (*p == c) { 5576612Stshiozak /* LINTED interface specification */ 5676612Stshiozak return (wchar_t *)p; 5776612Stshiozak } 5876612Stshiozak p--; 5976612Stshiozak } 6076612Stshiozak return NULL; 6176612Stshiozak} 62