| 656 | |
| 657 | |
| 658 | int Binary_string::strstr(const char *search, uint32 search_length, uint32 offset) const |
| 659 | { |
| 660 | if (search_length + offset <= str_length) |
| 661 | { |
| 662 | if (!search_length) |
| 663 | return ((int) offset); // Empty string is always found |
| 664 | |
| 665 | const char *str= Ptr + offset; |
| 666 | const char *end= Ptr + str_length - search_length + 1; |
| 667 | const char *search_end= search + search_length; |
| 668 | skip: |
| 669 | while (str != end) |
| 670 | { |
| 671 | if (*str++ == *search) |
| 672 | { |
| 673 | char *i= (char*) str; |
| 674 | char *j= (char*) search + 1 ; |
| 675 | while (j != search_end) |
| 676 | if (*i++ != *j++) goto skip; |
| 677 | return (int) (str-Ptr) -1; |
| 678 | } |
| 679 | } |
| 680 | } |
| 681 | return -1; |
| 682 | } |
| 683 | |
| 684 | int Binary_string::strstr(const Binary_string &s, uint32 offset) const |
| 685 | { |