| * Copyright (C) 2008 Bernhard Reutner-Fischer |
| * Licensed under GPLv2 or later, see file License in this tarball for details. |
| * The strrstr() function finds the last occurrence of the substring needle |
| * in the string haystack. The terminating nul characters are not compared. |
| char* FAST_FUNC strrstr(const char *haystack, const char *needle) |
| return (char*)haystack + strlen(haystack); |
| char *p = strstr(haystack, needle); |
| int main(int argc, char **argv) |
| { "baaabaaab", "aaa", 5 }, |
| { "baaabaaaab", "aaa", 6 }, |
| { "baaabaab", "aaa", 1 }, |
| while (i < sizeof(test_array) / sizeof(test_array[0])) { |
| const char *r = strrstr(test_array[i].h, test_array[i].n); |
| printf("'%s' vs. '%s': '%s' - ", test_array[i].h, test_array[i].n, r); |
| printf("%s\n", r == test_array[i].h + test_array[i].pos ? "PASSED" : "FAILED"); |