pgsql: Simplify pg_enc2gettext_tbl[] with C99-designated initializer sy

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Simplify pg_enc2gettext_tbl[] with C99-designated initializer sy
Date: 2024-03-01 09:05:03
Message-ID: E1rfypC-001W87-RB@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Simplify pg_enc2gettext_tbl[] with C99-designated initializer syntax

This commit switches pg_enc2gettext_tbl[] in encnames.c to use a
C99-designated initializer syntax.

pg_bind_textdomain_codeset() is simplified so as it is possible to do
a direct lookup at the gettext() array with a value of the enum pg_enc
rather than doing a loop through all its elements, as long as the
encoding value provided by GetDatabaseEncoding() is in the correct range
of supported encoding values. Note that PG_MULE_INTERNAL gains a value
in the array, pointing to NULL.

Author: Jelte Fennema-Nio
Discussion: https://postgr.es/m/CAGECzQT3caUbcCcszNewCCmMbCuyP7XNAm60J3ybd6PN5kH2Dw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/655dc310460c601d434d05339b7fa46ed97675b3

Modified Files
--------------
src/backend/utils/mb/mbutils.c | 24 +++++------
src/common/encnames.c | 86 ++++++++++++++++++++--------------------
src/include/mb/pg_wchar.h | 11 ++---
src/tools/pgindent/typedefs.list | 1 -
4 files changed, 55 insertions(+), 67 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2024-03-01 23:15:26 pgsql: Return ssize_t in fd.c I/O functions.
Previous Message Amit Kapila 2024-03-01 05:06:06 pgsql: Fix BF failure introduced by commit b3f6b14cf4.