aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-06-18 08:32:25 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-06-18 08:32:25 +0000
commit4954d47ab01624855fdf4bcf0a86fb86f6381638 (patch)
tree485cc14e7fa73ff69a308cb6bc63c190c65ac408 /libbb
parent619b87dfa51588cc81c779f074c4532e18c0dbb1 (diff)
downloadbusybox-w32-4954d47ab01624855fdf4bcf0a86fb86f6381638.tar.gz
busybox-w32-4954d47ab01624855fdf4bcf0a86fb86f6381638.tar.bz2
busybox-w32-4954d47ab01624855fdf4bcf0a86fb86f6381638.zip
- fixes from Tito
Diffstat (limited to 'libbb')
-rw-r--r--libbb/strrstr.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/libbb/strrstr.c b/libbb/strrstr.c
index 5a2685920..126fed75c 100644
--- a/libbb/strrstr.c
+++ b/libbb/strrstr.c
@@ -13,19 +13,16 @@
13 * The strrstr() function finds the last occurrence of the substring needle 13 * The strrstr() function finds the last occurrence of the substring needle
14 * in the string haystack. The terminating nul characters are not compared. 14 * in the string haystack. The terminating nul characters are not compared.
15 */ 15 */
16char* strrstr(const char *haystack, const char *needle) 16char *strrstr(const char *haystack, const char *needle)
17{ 17{
18 char *r = NULL; 18 char *r = NULL;
19 19
20 if (!needle[0]) 20 do {
21 return r; 21 char *p = strstr(haystack, needle);
22 while (1) { 22 if (p)
23 char *p = strstr(haystack, needle);
24 if (!p)
25 return r;
26 r = p; 23 r = p;
27 haystack = p + 1; 24 } while (*haystack++);
28 } 25 return r;
29} 26}
30 27
31#ifdef __DO_STRRSTR_TEST 28#ifdef __DO_STRRSTR_TEST