Re: [HACKERS] snprintf causes regression tests to fail

Joerg Hessdoerfer <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32
Organization S.E.A Datentechnik GmbH
Message-ID <[email protected]>
Hi,

On Wednesday 02 March 2005 01:28, you wrote:
> BTW, you should read the official spec for snprintf:
>
> http://www.opengroup.org/onlinepubs/007908799/xsh/fprintf.html
>
> There are a couple of interesting things that the present code is most
> certainly not doing correctly, notably:
>
>      In format strings containing the %n$ form of conversion
>      specifications, numbered arguments in the argument list can be
>      referenced from the format string as many times as required.
>
> Also it seems that runtime precision specs are required to have explicit
> numbers when used in a %n$ string, which is something I didn't know
> until just now.  This example in the spec is instructive:
>  printf("%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec);
>
> It might be a good idea to go look at whichever *BSD we got this code
> from originally, and see if they've upgraded it to do %n$.  'Cause it
> will take a nontrivial amount of work to get from where we are now to
> something that follows the full spec.
>

don't know if PG borrowed the code from here, but according to the manpage 
FreeBSD 5.3 seems to have a quite complete implementation, see
http://www.freebsd.org/cgi/man.cgi?query=snprintf&apropos=0&sektion=3&manpath=FreeBSD+5.3-RELEASE+and+Ports&format=html 


Would this help?

Greetings,
 Jörg
-- 
Leading SW developer  - S.E.A GmbH
Mail: [email protected]
WWW:  http://www.sea-gmbh.com

---------------------------(end of broadcast)---------------------------
TIP 3: 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.