svn commit: trunk/busybox/libbb

aldot at busybox.net aldot at busybox.net
Wed Jun 18 08:32:26 UTC 2008


Author: aldot
Date: 2008-06-18 01:32:25 -0700 (Wed, 18 Jun 2008)
New Revision: 22405

Log:
- fixes from Tito


Modified:
   trunk/busybox/libbb/strrstr.c


Changeset:
Modified: trunk/busybox/libbb/strrstr.c
===================================================================
--- trunk/busybox/libbb/strrstr.c	2008-06-18 06:57:07 UTC (rev 22404)
+++ trunk/busybox/libbb/strrstr.c	2008-06-18 08:32:25 UTC (rev 22405)
@@ -13,19 +13,16 @@
  * The strrstr() function finds the last occurrence of the substring needle
  * in the string haystack. The terminating nul characters are not compared.
  */
-char* strrstr(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




More information about the busybox-cvs mailing list