| 189 |
189 |
| 190 cxstring cx_strchr_( |
190 cxstring cx_strchr_( |
| 191 cxstring string, |
191 cxstring string, |
| 192 int chr |
192 int chr |
| 193 ) { |
193 ) { |
| 194 char *ret = memchr(string.ptr, 0xFF & chr, string.length); |
194 const char *ret = memchr(string.ptr, 0xFF & chr, string.length); |
| 195 if (ret == NULL) return (cxstring) {NULL, 0}; |
195 if (ret == NULL) return (cxstring) {NULL, 0}; |
| 196 return (cxstring) {ret, string.length - (ret - string.ptr)}; |
196 return (cxstring) {ret, string.length - (ret - string.ptr)}; |
| 197 } |
197 } |
| 198 |
198 |
| 199 cxstring cx_strrchr_( |
199 cxstring cx_strrchr_( |
| 200 cxstring string, |
200 cxstring string, |
| 201 int chr |
201 int chr |
| 202 ) { |
202 ) { |
| 203 #ifdef WITH_MEMRCHR |
203 #ifdef WITH_MEMRCHR |
| 204 char *ret = memrchr(string.ptr, 0xFF & chr, string.length); |
204 const char *ret = memrchr(string.ptr, 0xFF & chr, string.length); |
| 205 if (ret == NULL) return (cxstring) {NULL, 0}; |
205 if (ret == NULL) return (cxstring) {NULL, 0}; |
| 206 return (cxstring) {ret, string.length - (ret - string.ptr)}; |
206 return (cxstring) {ret, string.length - (ret - string.ptr)}; |
| 207 #else |
207 #else |
| 208 chr = 0xFF & chr; |
208 chr = 0xFF & chr; |
| 209 size_t i = string.length; |
209 size_t i = string.length; |