Re: [HACKERS] snprintf causes regression tests to fail

Nicolai Tufar <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32
Message-ID <[email protected]>
On Tue, 1 Mar 2005 22:42:52 +0100, Joerg Hessdoerfer
<[email protected]> wrote:
> 
> Some stupid idea just crossed my mind: what if the /ports version just
> re-arranges the va_list according to the positional args and calls
> vsnprintf()?
> At least we know compiler and library...

I thought about it a lot. Some platforms do not support
all of % formant strings. src/port/snprintf.c is used both
for the platforms that do not support all necessary
% modifiers and the ones that do not support %n$ 
modifiers. Here is a comment from configure:

# If we found "long int" is 64 bits, assume snprintf handles it.  If
# we found we need to use "long long int", better check.  We cope with
# snprintfs that use %lld, %qd, or %I64d as the format.  If none of these
# work, fall back to our own snprintf emulation (which we know uses %lld).
 
Any comments on this idea? Should we have two
versions of snprintf.c for these occasions?

> Or, another idea: why not format the va_args individually using the original
> format specifiers alone (without positional args), and assemble the resulting
> string?

That is exactly what the code does :)

> Greetings,
>  Jörg

Nick

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match
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.