Update copyright notices with scripts/update-copyrights.
[jlayton/glibc.git] / sysdeps / powerpc / powerpc32 / power6 / wcschr.c
1 /* wcschr.c - Wide Character Search for powerpc32/power6.
2    Copyright (C) 2012-2013 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If
17    not, see <http://www.gnu.org/licenses/>.  */
18
19 #include <wchar.h>
20
21
22 /* Find the first occurrence of WC in WCS.  */
23 wchar_t *
24 wcschr (wcs, wc)
25      register const wchar_t *wcs;
26      register const wchar_t wc;
27 {
28   register const wchar_t *wcs2 = wcs + 1;
29
30   if (*wcs == wc)
31     return (wchar_t *) wcs;
32   if (*wcs == L'\0')
33     return NULL;
34
35   do
36     {
37       wcs += 2;
38
39       if (*wcs2 == wc)
40         return (wchar_t *) wcs2;
41       if (*wcs2 == L'\0')
42         return NULL;
43        wcs2 += 2;
44
45       if (*wcs == wc)
46         return (wchar_t *) wcs;
47       if (*wcs == L'\0')
48         return NULL;
49       wcs += 2;
50
51       if (*wcs2 == wc)
52         return (wchar_t *) wcs2;
53       if (*wcs2 == L'\0')
54         return NULL;
55       wcs2 += 2;
56
57       if (*wcs == wc)
58         return (wchar_t *) wcs;
59       if (*wcs == L'\0')
60         return NULL;
61       wcs += 2;
62
63       if (*wcs2 == wc)
64         return (wchar_t *) wcs2;
65       if (*wcs2 == L'\0')
66         return NULL;
67       wcs2 += 2;
68
69       if (*wcs == wc)
70         return (wchar_t *) wcs;
71       if (*wcs == L'\0')
72         return NULL;
73       wcs += 2;
74
75       if (*wcs2 == wc)
76         return (wchar_t *) wcs2;
77       if (*wcs2 == L'\0')
78         return NULL;
79       wcs2 += 2;
80
81       if (*wcs == wc)
82         return (wchar_t *) wcs;
83     }
84   while (*wcs != L'\0');
85
86   return NULL;
87 }
88 libc_hidden_def (wcschr)