Hello Tito,

2015-08-24 21:29 GMT+02:00 Tito <farmat...@tiscali.it>:
> So as you can see they explicitly request a specific action for the case
> of a zero length key:
>
>     "If s2 points to a string with zero length, the function shall return
> s1."
>
> Not that I like their solution but still this is a fact and makes me
> think that we should also handle this corner case in better way
> rather than return a "useless value".

uClibc does exactly that, but doesn't treat an empty key in a special
way. It simply returns full string as a 'side effect' of the search
algorithm used.

That said, I have realized now that there's a previous similar
function called is_prefixed_with, which finds if a string starts with
a key and returns the rest of the string if found (i.e. the string
without the prefix).

And, as already has said Bartosz, maybe the correct name for ends_with
may be is_suffixed_with. But for consistency it should also return the
string at the position of the match or something like that. But until
it's return value is not consistent with is_prefixed_with, I would
*leave* it as ends_with to prevent confusion.

Cheers,

Xabier Oneca_,,_
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to