]> git.ipfire.org Git - thirdparty/glibc.git/blame - wcsmbs/wcschr.c
alloc_buffer: Return unqualified pointer type in alloc_buffer_next
[thirdparty/glibc.git] / wcsmbs / wcschr.c
CommitLineData
04277e02 1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
6d52618b 2 This file is part of the GNU C Library.
a482b5a5 3
6d52618b 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
a482b5a5 8
6d52618b
UD
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
a482b5a5 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
a482b5a5 17
299a95b9 18#include <wchar.h>
7ba0100c 19#include <loop_unroll.h>
a482b5a5 20
fb78612a
AZ
21#ifndef WCSCHR
22# define WCSCHR __wcschr
1d3e4b61
UD
23#endif
24
fb78612a 25/* Find the first occurrence of WC in WCS. */
a482b5a5 26wchar_t *
fb78612a 27WCSCHR (const wchar_t *wcs, const wchar_t wc)
a482b5a5 28{
7ba0100c 29 wchar_t *dest = NULL;
a482b5a5 30
7ba0100c
AZ
31#define ITERATION(index) \
32 ({ \
33 if (*wcs == wc) \
34 dest = (wchar_t*) wcs; \
35 dest == NULL && *wcs++ != L'\0'; \
36 })
37
38#ifndef UNROLL_NTIMES
39# define UNROLL_NTIMES 1
40#endif
41
42 while (1)
43 UNROLL_REPEAT (UNROLL_NTIMES, ITERATION);
44
45 return dest;
a482b5a5 46}
fb78612a 47libc_hidden_def (__wcschr)
2cfbdb9a
JM
48weak_alias (__wcschr, wcschr)
49libc_hidden_weak (wcschr)