On Mon, Jun 16, 2008 at 09:48:07PM +0200, Tito wrote:
>On Monday 16 June 2008 09:47:31 Bernhard Fischer wrote:
>> On Mon, Jun 16, 2008 at 08:45:18AM +0200, Tito wrote:
>> >On Monday 16 June 2008 06:33:35 you wrote:
>> >> 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;
>> >> r = p;
>> >> haystack = p + 1;
>Hi, just for fun,
>one more variant that seems to pass the tests as modified (for "")
>
>char* strrstr(const char *haystack, const char *needle)
>{
> char *s = NULL;
>
> while (*haystack) {
> s = (strstr(haystack++, needle)) ? : s;
> }
> return s;
>}
>
>but size on my system is the same as Denys' version.... :(
>
>scripts/bloat-o-meter busybox_old busybox_unstripped
>function old new delta
>strrstr 53 42 -11
>------------------------------------------------------------------------------
>(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-11) Total: -11 bytes
Tito, can you pick one (your decision) and send me the full file
(including your nice testcases)?
TIA and cheers,
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox