Re: Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt

From: Date: Sat, 05 Jan 2002 18:57:55 +0000
Subject: Re: Re: cvs: php4 /ext/standard string.c /ext/standard/tests/strings wordwrap.phpt
References: 1 2 3 4  Groups: php.dev 
Request: Send a blank email to php-dev+get-75966@lists.php.net to get a copy of this message
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

« previous php.dev (#75966) next »