| 1413 | } |
| 1414 | |
| 1415 | const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) |
| 1416 | { |
| 1417 | if (!needle_end) |
| 1418 | needle_end = needle + strlen(needle); |
| 1419 | |
| 1420 | const char un0 = (char)toupper(*needle); |
| 1421 | while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end)) |
| 1422 | { |
| 1423 | if (toupper(*haystack) == un0) |
| 1424 | { |
| 1425 | const char* b = needle + 1; |
| 1426 | for (const char* a = haystack + 1; b < needle_end; a++, b++) |
| 1427 | if (toupper(*a) != toupper(*b)) |
| 1428 | break; |
| 1429 | if (b == needle_end) |
| 1430 | return haystack; |
| 1431 | } |
| 1432 | haystack++; |
| 1433 | } |
| 1434 | return NULL; |
| 1435 | } |
| 1436 | |
| 1437 | // Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible. |
| 1438 | void ImStrTrimBlanks(char* buf) |