Re: snprintf heads-up
| From: | Zeev Suraski | Date: | Fri, 08 Sep 2000 14:17:37 +0000 |
| Subject: | Re: snprintf heads-up | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-32670@lists.php.net to get a copy of this message | ||
On Fri, 8 Sep 2000, Stanislav Malyshev wrote:
> ZS>> written. As it doesn't always appear to be the case, the best approach
>
> More precisely, it almost always is not the case, once the 'n' part comes
> into play.
Well, right now this is the behavior whenever there's no system-supplied
snprintf() (again, assuming that's the way snprintf.c really behaves,
which needs to be tested).
> ZS>> IMHO would be using the bundled snprintf() always, regardless of whether
> ZS>> snprintf() is available on the platform.
> ZS>> As far as I can tell from glancing through snprintf.c, this version of
> ZS>> snprintf() would return the number of characters that were effectively
> ZS>> written under all circumstances (I could be wrong, we need to test it).
>
> That would be highly confusing behaviour - calling something snprintf
> where it isn't snprintf. Then we better call it safe_snprintf or something
> like that.
Perhaps. snprintf() isn't standard yet, and as we saw, there are several
different behaviors on different platforms to begin with. But I guess
that seeing one thing in a manpage and experiencing a different behavior
in practice could get confusing. I'd use php_snprintf().
Zeev
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/