This source file includes following definitions.
- u8_strchr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include <config.h>
28
29
30 #include "unistr.h"
31
32 #include <string.h>
33
34 uint8_t *
35 u8_strchr (const uint8_t *s, ucs4_t uc)
36 {
37 uint8_t c[6];
38
39 if (uc < 0x80)
40 {
41 uint8_t c0 = uc;
42
43 if (false)
44 {
45
46 for (;;)
47 {
48 uint8_t s0 = *s;
49 if (s0 == c0)
50 return (uint8_t *) s;
51 s++;
52 if (s0 == 0)
53 break;
54 }
55 }
56 else
57 {
58
59
60
61 return (uint8_t *) strchr ((const char *) s, c0);
62 }
63 }
64 else
65
66
67
68
69
70 switch (u8_uctomb_aux (c, uc, 6))
71 {
72 case 2:
73 if (*s == 0 || s[1] == 0)
74 break;
75 {
76 uint8_t c0 = c[0];
77 uint8_t c1 = c[1];
78
79 uint8_t s1 = s[1];
80
81 for (;;)
82 {
83
84
85 if (s1 == c1)
86 {
87 if (*s == c0)
88 return (uint8_t *) s;
89 else
90
91 goto case2_skip2;
92 }
93 else
94 {
95 if (s1 == c0)
96 goto case2_skip1;
97 else
98
99 goto case2_skip2;
100 }
101 case2_skip2:
102 s++;
103 s1 = s[1];
104 if (s[1] == 0)
105 break;
106 case2_skip1:
107 s++;
108 s1 = s[1];
109 if (s[1] == 0)
110 break;
111 }
112 }
113 break;
114
115 case 3:
116 if (*s == 0 || s[1] == 0 || s[2] == 0)
117 break;
118 {
119 uint8_t c0 = c[0];
120 uint8_t c1 = c[1];
121 uint8_t c2 = c[2];
122
123 uint8_t s2 = s[2];
124
125 for (;;)
126 {
127
128
129 if (s2 == c2)
130 {
131 if (s[1] == c1 && *s == c0)
132 return (uint8_t *) s;
133 else
134
135
136
137 if (c2 == c1)
138 goto case3_skip1;
139 else
140 goto case3_skip3;
141 }
142 else
143 {
144 if (s2 == c1)
145 goto case3_skip1;
146 else if (s2 == c0)
147
148 goto case3_skip2;
149 else
150
151
152 goto case3_skip3;
153 }
154 case3_skip3:
155 s++;
156 s2 = s[2];
157 if (s[2] == 0)
158 break;
159 case3_skip2:
160 s++;
161 s2 = s[2];
162 if (s[2] == 0)
163 break;
164 case3_skip1:
165 s++;
166 s2 = s[2];
167 if (s[2] == 0)
168 break;
169 }
170 }
171 break;
172
173 case 4:
174 if (*s == 0 || s[1] == 0 || s[2] == 0 || s[3] == 0)
175 break;
176 {
177 uint8_t c0 = c[0];
178 uint8_t c1 = c[1];
179 uint8_t c2 = c[2];
180 uint8_t c3 = c[3];
181
182 uint8_t s3 = s[3];
183
184 for (;;)
185 {
186
187
188 if (s3 == c3)
189 {
190 if (s[2] == c2 && s[1] == c1 && *s == c0)
191 return (uint8_t *) s;
192 else
193
194
195
196
197
198 if (c3 == c2)
199 goto case4_skip1;
200 else if (c3 == c1)
201 goto case4_skip2;
202 else
203 goto case4_skip4;
204 }
205 else
206 {
207 if (s3 == c2)
208 goto case4_skip1;
209 else if (s3 == c1)
210
211 goto case4_skip2;
212 else if (s3 == c0)
213
214
215 goto case4_skip3;
216 else
217
218
219
220 goto case4_skip4;
221 }
222 case4_skip4:
223 s++;
224 s3 = s[3];
225 if (s[3] == 0)
226 break;
227 case4_skip3:
228 s++;
229 s3 = s[3];
230 if (s[3] == 0)
231 break;
232 case4_skip2:
233 s++;
234 s3 = s[3];
235 if (s[3] == 0)
236 break;
237 case4_skip1:
238 s++;
239 s3 = s[3];
240 if (s[3] == 0)
241 break;
242 }
243 }
244 break;
245 }
246
247 return NULL;
248 }