At 10:44 AM 1/5/2002 -0800, Jim Winstead wrote:
>On Sat, Jan 05, 2002 at 08:22:24PM +0200, Andi Gutmans wrote:
> > You're missing the point. In order to minimize the amount of API misuse of
> > the str*cat() family of functions we decided only to use the ones I
> > mentioned, everywhere. I am sure that you're code is correct but all 
> places
> > should use strlcat()/strlcpy() if they are using the str* family of
> > functions.
>
>in all due respect, i think you're missing my point. wordwrap() copies
>chunks from the middle of the source string to the end of the
>destination string. neither strlcpy() nor strlcat() is useful in this
>situation, because all they take is the length of the destination
>buffer, not a length of characters to copy from the source.
>
>   char *source = "this is my string";
>   strncpy(dest, source+5, 5); // copy 'is my' to dest.

Yes you are right. In this case you should use memcpy().


>i guess you could use strlcat() if you kept track of the current end
>position of the destination string and then lied about the size of the
>destination string so only the right number of characters were copied
>from the source, but that seems a rather obtuse way to do it.

Nah, it's not meant to be used that way.

>in any case, i'm working on a memcpy()-based rewrite. i don't know that
>it is really useful for wordwrap() to be binary-safe, but that will be
>one of the side-effects. :)

Even better :)

Andi


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to