apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <...@ntrnet.net>
Subject Re: apr_snprintf not compliant
Date Sun, 25 Aug 2002 17:46:12 GMT
On Sun, 25 Aug 2002, Ben Laurie wrote:

> Ryan Bloom wrote:
> > On Fri, 23 Aug 2002, Jim Jagielski wrote:
> > 
> > 
> >>We are already not compliant, since we overload %p.
> >>
> >>Not sure if I understand #1: If len is 0, we return 0 and don't check
> >>buff at all. Or do you mean a length of 0 (or 1) should set
> >>*buffer to NULL?
> > 
> > 
> > right now, if length is 0, we return 0, and that is it.  However, the spec
> > says that if length is zero, then *buffer is allowed to be NULL, but
> > whether it is or isn't, *buffer isn't modified, and snprintf returns the
> > number of characters that _would_ be returned if length was infinite.
> > 
> > An example:
> > 
> > apr_snprintf(p, NULL, 0, "%s BAR", "FOO");
> > 
> > currently returns 0, after the changes, it would return 7.
> 
> 8, surely?

Nope, 7, unless I counted wrong.  3 for "FOO", 3 for BAR, and 1 for the
space.  snprintf doesn't include the \0.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------


Mime
View raw message