| 1754 | } |
| 1755 | |
| 1756 | const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) |
| 1757 | { |
| 1758 | if (!needle_end) |
| 1759 | needle_end = needle + strlen(needle); |
| 1760 | |
| 1761 | const char un0 = (char)ImToUpper(*needle); |
| 1762 | while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end)) |
| 1763 | { |
| 1764 | if (ImToUpper(*haystack) == un0) |
| 1765 | { |
| 1766 | const char* b = needle + 1; |
| 1767 | for (const char* a = haystack + 1; b < needle_end; a++, b++) |
| 1768 | if (ImToUpper(*a) != ImToUpper(*b)) |
| 1769 | break; |
| 1770 | if (b == needle_end) |
| 1771 | return haystack; |
| 1772 | } |
| 1773 | haystack++; |
| 1774 | } |
| 1775 | return NULL; |
| 1776 | } |
| 1777 | |
| 1778 | // 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. |
| 1779 | void ImStrTrimBlanks(char* buf) |