Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-hackers-win32 by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group