| 269 | } |
| 270 | |
| 271 | char* strstr(const char *str, const char *pat) { |
| 272 | unsigned char* s1 = (unsigned char*)str - 1; |
| 273 | unsigned char* p1 = (unsigned char*)pat - 1; |
| 274 | unsigned long firstc, c1, c2; |
| 275 | |
| 276 | if ((pat == 0) || (!(firstc = *++p1))) { |
| 277 | return ((char*)str); |
| 278 | } |
| 279 | |
| 280 | while (c1 = *++s1) { |
| 281 | if (c1 == firstc) { |
| 282 | const unsigned char* s2 = s1 - 1; |
| 283 | const unsigned char* p2 = p1 - 1; |
| 284 | |
| 285 | while ((c1 = *++s2) == (c2 = *++p2) && c1) { |
| 286 | |
| 287 | } |
| 288 | |
| 289 | if (!c2) { |
| 290 | return ((char*)s1); |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | return NULL; |
| 296 | } |
| 297 | |
| 298 | void strerror(void) |
| 299 | { |
no outgoing calls
no test coverage detected