Re: more C99 cleanup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: more C99 cleanup
Date: 2025-11-21 15:35:16
Message-ID: 2182909.1763739316@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
> I have been hunting down the last few pieces of code that made some
> obsolete claims about not being able to use C99 yet or needing to be
> compatible with pre-C99 or something like that. I found two obsolete
> comments and two places where we could now actually use the C99
> functionality that the comment was anticipating.

Two comments:

* In 0001,

- * This implementation conforms to IEEE Std 1003.1 and GLIBC, in that the
- * case of hypot(inf,nan) results in INF, and not NAN.

I have a distinct recollection that this comment exists because we
found that some platforms had a hypot() that got that edge case wrong.
I don't object to proceeding on the assumption that they all conform
to spec by now, but please make sure there's at least one regression
test that will expose the problem if someplace doesn't. (A quick check
would be to hot-wire pg_hypot to do the wrong thing and see if any
existing test falls over. I think there is one, but let's verify.)

* In 0003, we can't be very sure what "isblank((unsigned char) c)"
will do with non-ASCII input data, except that it could very
easily do insane things with fragments of a multibyte character.
I recommend keeping pg_isblank but redefining it along the lines of

bool
pg_isblank(unsigned char c)
{
return (!IS_HIGHBIT_SET(c) && isblank(c));
}

to ensure the previous treatment of non-ASCII data.
(It could be made static in hba.c, perhaps)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-11-21 15:55:12 Re: headerscheck ccache support
Previous Message Matthias van de Meent 2025-11-21 15:25:06 Re: Expanding HOT updates for expression and partial indexes