diff options
author | tjr <tjr@FreeBSD.org> | 2002-10-23 10:47:47 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-10-23 10:47:47 +0000 |
commit | f0735aa8f5cba3f083ed71230c6ebe4928b9bb58 (patch) | |
tree | 696ca8efdee0fa20ae68a885b03b657f266e13c8 | |
parent | e3a940d2bf5f2388fa18ce1fb13e7dd1ee05e08f (diff) | |
download | FreeBSD-src-f0735aa8f5cba3f083ed71230c6ebe4928b9bb58.zip FreeBSD-src-f0735aa8f5cba3f083ed71230c6ebe4928b9bb58.tar.gz |
Reimplement, handling the case where c == L'\0' correctly and fixing
some style(9) bugs.
-rw-r--r-- | lib/libc/string/wcschr.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/lib/libc/string/wcschr.c b/lib/libc/string/wcschr.c index 3a81488..1df1fe6 100644 --- a/lib/libc/string/wcschr.c +++ b/lib/libc/string/wcschr.c @@ -1,5 +1,5 @@ /*- - * Copyright (c)1999 Citrus Project, + * Copyright (c) 2002 Tim J. Robbins * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,34 +22,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * citrus Id: wcschr.c,v 1.2 2000/12/21 05:07:25 itojun Exp */ #include <sys/cdefs.h> -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcschr.c,v 1.1 2000/12/23 23:14:36 itojun Exp $"); -#endif /* LIBC_SCCS and not lint */ -#endif __FBSDID("$FreeBSD$"); #include <wchar.h> wchar_t * -wcschr(s, c) - const wchar_t *s; - wchar_t c; +wcschr(const wchar_t *s, wchar_t c) { - const wchar_t *p; - p = s; - while (*p) { - if (*p == c) { - /* LINTED interface specification */ - return (wchar_t *)p; - } - p++; - } - return NULL; + while (*s != c && *s != L'\0') + s++; + if (*s == c) + return ((wchar_t *)s); + return (NULL); } |