Re: snprintf() - Mailing list pgsql-hackers

From Kate F
Subject Re: snprintf()
Date
Msg-id 20070203041125.GI390@cats.meow.at
Whole thread Raw
In response to Re: snprintf()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: snprintf()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Feb/ 2/07 10:52:28PM -0500, Tom Lane wrote:
> Kate F <kate@cats.meow.at> writes:
> > ... does PostgreSQL replace my system's snprintf() prototype with
> > its own implementation's?
> 
> We do on some platforms where configure decides the system version
> is deficient ... I don't recall the exact conditions at the moment.
> I wouldn't really have expected that to happen on any *BSD, but you
> could look into the generated Makefile.global to find out.

I don't see anything that looks relevant for my Makefile.global; I
would be surprised if NetBSD's were overridden too!


> > For reference, the relevant part of C99:
> >   7.19.6.5 2 If n is zero, nothing is written, and s may be a null
> >   pointer.
> 
> For reference, the relevant part of the Single Unix Spec:
> 
>     If the value of n is zero on a call to snprintf(), an
>     unspecified value less than 1 is returned.

Aha! I do recall either POSIX or SUS defers to C on conflicts... I
can't find which, though. If this snprintf() is following SUS
behaviour, that's fine. Thank you!


> So the behavior you'd like to depend on is unportable anyway, and
> that coding will get rejected if submitted as a Postgres patch.

Absolutley (and I assume you target C89, too, which does not provide
snprintf()). This was just something personal where I happened to use
it for convenience.

Thank you for checking that - and appologies for posting to the wrong
list; that should have been to -bugs!

Regards,

-- 
Kate


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: snprintf()
Next
From: Tom Lane
Date:
Subject: Re: snprintf()