- fixes from Tito
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 18 Jun 2008 08:32:25 +0000 (08:32 -0000)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 18 Jun 2008 08:32:25 +0000 (08:32 -0000)
libbb/strrstr.c

index 5a2685920f4a8c8026c171ce634a56dd745a5bb7..126fed75cea40787e51327f393596911e0352715 100644 (file)
  * The strrstr() function finds the last occurrence of the substring needle
  * in the string haystack. The terminating nul characters are not compared.
  */
-charstrrstr(const char *haystack, const char *needle)
+char *strrstr(const char *haystack, const char *needle)
 {
        char *r = NULL;
-
-       if (!needle[0])
-                       return r;
-       while (1) {
-                       char *p = strstr(haystack, needle);
-                       if (!p)
-                                       return r;
+       
+       do {
+               char *p = strstr(haystack, needle);
+               if (p)
                        r = p;
-                       haystack = p + 1;
-       }
+       } while (*haystack++);
+       return r;
 }
 
 #ifdef __DO_STRRSTR_TEST