Re: [HACKERS] snprintf causes regression tests to fail

From: Nicolai Tufar <ntufar(at)gmail(dot)com>
To: Joerg Hessdoerfer <Joerg(dot)Hessdoerfer(at)sea-gmbh(dot)com>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers-win32(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] snprintf causes regression tests to fail
Date: 2005-03-01 21:59:10
Message-ID: d809293905030113594b4fcd18@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

On Tue, 1 Mar 2005 22:42:52 +0100, Joerg Hessdoerfer
<Joerg(dot)Hessdoerfer(at)sea-gmbh(dot)com> 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Wong 2005-03-01 22:06:42 Re: 8.0.X and the ARC patent
Previous Message Tom Lane 2005-03-01 21:57:11 Re: 8.0.X and the ARC patent

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Tom Lane 2005-03-01 22:13:06 Re: [HACKERS] snprintf causes regression tests to fail
Previous Message Joerg Hessdoerfer 2005-03-01 21:42:52 Re: [HACKERS] snprintf causes regression tests to fail