On Mon, Dec 05, 2005 at 04:35:31PM -0500, Bruce Momjian wrote:
> 
> but it seems this is some BSD'ism that we don't need to support if the
> standard doesn't say so.

I think the Linux manpage is more informative about this:

       The functions snprintf and vsnprintf do not write more  than
       size  bytes (including the trailing '\0').  If the output was truncated
       due to this limit then the return value is  the  number  of  characters
       (not  including the trailing '\0') which would have been written to the
       final string if enough space had been available. Thus, a  return  value
       of  size  or  more means that the output was truncated. (See also below
       under NOTES.)  If an output error is encountered, a negative  value  is
       returned.

[...]

NOTES
       The  glibc  implementation  of the functions snprintf() and vsnprintf()
       conforms to the C99 standard, i.e., behaves as described  above,  since
       glibc version 2.1. Until glibc 2.0.6 they would return -1 when the out-
       put was truncated.

[...]

       Concerning  the return value of snprintf(), the SUSv2 and the C99 stan-
       dard contradict each other: when snprintf() is called with size=0  then
       SUSv2  stipulates  an  unspecified  return value less than 1, while C99
       allows str to be NULL in this case, and  gives  the  return  value  (as
       always)  as  the  number  of characters that would have been written in
       case the output string has been large enough.


Kurt


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to