Re: more POSIX 2008 cleanup: strnlen(), rindex()

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jelte Fennema-Nio <postgres@jeltef.nl>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-01-03T17:42:55Z
Lists: pgsql-hackers
Jelte Fennema-Nio <postgres@jeltef.nl> writes:
> On Sat, 3 Jan 2026 at 10:52, Peter Eisentraut <peter@eisentraut.org> wrote:
>> It has previously been established that POSIX 2008 is the baseline for
>> PostgreSQL code (modulo Windows).  Looking through the POSIX 2008
>> changes, I found a few more things we can clean up with respect to that.

> Both changes look sensible to me

+1.  I also checked the buildfarm and confirm that no animals report
not having strnlen().

I'm a little disturbed by the rindex bit, because that's not hoary old
code: it came in with JIT in v11, only about 8 years ago.  How can we
prevent similar mistakes in future?

			regards, tom lane



Commits

  1. Remove use of rindex() function

  2. strnlen() is now required

  3. Add pg_strnlen() a portable implementation of strlen.