| 283 | */ |
| 284 | #ifndef RT_KLIBC_USING_USER_STRSTR |
| 285 | char *rt_strstr(const char *s1, const char *s2) |
| 286 | { |
| 287 | #ifdef RT_KLIBC_USING_LIBC_STRSTR |
| 288 | return strstr(s1, s2); |
| 289 | #else |
| 290 | int l1 = 0, l2 = 0; |
| 291 | |
| 292 | l2 = rt_strlen(s2); |
| 293 | if (!l2) |
| 294 | { |
| 295 | return (char *)s1; |
| 296 | } |
| 297 | |
| 298 | l1 = rt_strlen(s1); |
| 299 | while (l1 >= l2) |
| 300 | { |
| 301 | l1 --; |
| 302 | if (!rt_memcmp(s1, s2, l2)) |
| 303 | { |
| 304 | return (char *)s1; |
| 305 | } |
| 306 | |
| 307 | s1 ++; |
| 308 | } |
| 309 | |
| 310 | return RT_NULL; |
| 311 | #endif /* RT_KLIBC_USING_LIBC_STRSTR */ |
| 312 | } |
| 313 | #endif /* RT_KLIBC_USING_USER_STRSTR */ |
| 314 | RTM_EXPORT(rt_strstr); |
| 315 |
no test coverage detected