Simplify pg_enc2gettext_tbl[] with C99-designated initializer syntax
authorMichael Paquier <michael@paquier.xyz>
Fri, 1 Mar 2024 09:03:48 +0000 (18:03 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 1 Mar 2024 09:03:48 +0000 (18:03 +0900)
commit655dc310460c601d434d05339b7fa46ed97675b3
tree9c502f28b148dea717d2f41ed14f541198dea806
parentdef0ce3370689b939c6d7a3c3eb824d69989ef6e
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
src/backend/utils/mb/mbutils.c
src/common/encnames.c
src/include/mb/pg_wchar.h
src/tools/pgindent/typedefs.list