Skip to content

Commit 420ea68

Browse files
committed
Move gettext encoding names into encnames.c, so we only have one place to update.
Per discussion.
1 parent 9563afa commit 420ea68

File tree

3 files changed

+60
-47
lines changed

3 files changed

+60
-47
lines changed

src/backend/utils/mb/encnames.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Encoding names and routines for work with it. All
33
* in this file is shared bedween FE and BE.
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.38 2009/02/10 19:29:39 petere Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.39 2009/04/24 08:43:50 mha Exp $
66
*/
77
#ifdef FRONTEND
88
#include "postgres_fe.h"
@@ -430,6 +430,49 @@ pg_enc2name pg_enc2name_tbl[] =
430430
}
431431
};
432432

433+
/* ----------
434+
* These are encoding names for gettext.
435+
* ----------
436+
*/
437+
pg_enc2gettext pg_enc2gettext_tbl[] =
438+
{
439+
{PG_UTF8, "UTF-8"},
440+
{PG_LATIN1, "LATIN1"},
441+
{PG_LATIN2, "LATIN2"},
442+
{PG_LATIN3, "LATIN3"},
443+
{PG_LATIN4, "LATIN4"},
444+
{PG_ISO_8859_5, "ISO-8859-5"},
445+
{PG_ISO_8859_6, "ISO_8859-6"},
446+
{PG_ISO_8859_7, "ISO-8859-7"},
447+
{PG_ISO_8859_8, "ISO-8859-8"},
448+
{PG_LATIN5, "LATIN5"},
449+
{PG_LATIN6, "LATIN6"},
450+
{PG_LATIN7, "LATIN7"},
451+
{PG_LATIN8, "LATIN8"},
452+
{PG_LATIN9, "LATIN-9"},
453+
{PG_LATIN10, "LATIN10"},
454+
{PG_KOI8R, "KOI8-R"},
455+
{PG_KOI8U, "KOI8-U"},
456+
{PG_WIN1250, "CP1250"},
457+
{PG_WIN1251, "CP1251"},
458+
{PG_WIN1252, "CP1252"},
459+
{PG_WIN1253, "CP1253"},
460+
{PG_WIN1254, "CP1254"},
461+
{PG_WIN1255, "CP1255"},
462+
{PG_WIN1256, "CP1256"},
463+
{PG_WIN1257, "CP1257"},
464+
{PG_WIN1258, "CP1258"},
465+
{PG_WIN866, "CP866"},
466+
{PG_WIN874, "CP874"},
467+
{PG_EUC_CN, "EUC-CN"},
468+
{PG_EUC_JP, "EUC-JP"},
469+
{PG_EUC_KR, "EUC-KR"},
470+
{PG_EUC_TW, "EUC-TW"},
471+
{PG_EUC_JIS_2004, "EUC-JP"},
472+
{0, NULL}
473+
};
474+
475+
433476
/* ----------
434477
* Encoding checks, for error returns -1 else encoding id
435478
* ----------

src/backend/utils/mb/mbutils.c

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Tatsuo Ishii
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.85 2009/04/08 09:50:48 heikki Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.86 2009/04/24 08:43:50 mha Exp $
88
*/
99
#include "postgres.h"
1010

@@ -890,47 +890,6 @@ cliplen(const char *str, int len, int limit)
890890
return l;
891891
}
892892

893-
#if defined(ENABLE_NLS)
894-
static const struct codeset_map {
895-
int encoding;
896-
const char *codeset;
897-
} codeset_map_array[] = {
898-
{PG_UTF8, "UTF-8"},
899-
{PG_LATIN1, "LATIN1"},
900-
{PG_LATIN2, "LATIN2"},
901-
{PG_LATIN3, "LATIN3"},
902-
{PG_LATIN4, "LATIN4"},
903-
{PG_ISO_8859_5, "ISO-8859-5"},
904-
{PG_ISO_8859_6, "ISO_8859-6"},
905-
{PG_ISO_8859_7, "ISO-8859-7"},
906-
{PG_ISO_8859_8, "ISO-8859-8"},
907-
{PG_LATIN5, "LATIN5"},
908-
{PG_LATIN6, "LATIN6"},
909-
{PG_LATIN7, "LATIN7"},
910-
{PG_LATIN8, "LATIN8"},
911-
{PG_LATIN9, "LATIN-9"},
912-
{PG_LATIN10, "LATIN10"},
913-
{PG_KOI8R, "KOI8-R"},
914-
{PG_KOI8U, "KOI8-U"},
915-
{PG_WIN1250, "CP1250"},
916-
{PG_WIN1251, "CP1251"},
917-
{PG_WIN1252, "CP1252"},
918-
{PG_WIN1253, "CP1253"},
919-
{PG_WIN1254, "CP1254"},
920-
{PG_WIN1255, "CP1255"},
921-
{PG_WIN1256, "CP1256"},
922-
{PG_WIN1257, "CP1257"},
923-
{PG_WIN1258, "CP1258"},
924-
{PG_WIN866, "CP866"},
925-
{PG_WIN874, "CP874"},
926-
{PG_EUC_CN, "EUC-CN"},
927-
{PG_EUC_JP, "EUC-JP"},
928-
{PG_EUC_KR, "EUC-KR"},
929-
{PG_EUC_TW, "EUC-TW"},
930-
{PG_EUC_JIS_2004, "EUC-JP"}
931-
};
932-
#endif /* ENABLE_NLS */
933-
934893
void
935894
SetDatabaseEncoding(int encoding)
936895
{
@@ -969,12 +928,12 @@ pg_bind_textdomain_codeset(const char *domainname)
969928
return;
970929
#endif
971930

972-
for (i = 0; i < lengthof(codeset_map_array); i++)
931+
for (i = 0; pg_enc2gettext_tbl[i].name != NULL; i++)
973932
{
974-
if (codeset_map_array[i].encoding == encoding)
933+
if (pg_enc2gettext_tbl[i].encoding == encoding)
975934
{
976935
if (bind_textdomain_codeset(domainname,
977-
codeset_map_array[i].codeset) == NULL)
936+
pg_enc2gettext_tbl[i].name) == NULL)
978937
elog(LOG, "bind_textdomain_codeset failed");
979938
break;
980939
}

src/include/mb/pg_wchar.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.89 2009/04/08 09:50:48 heikki Exp $
9+
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.90 2009/04/24 08:43:51 mha Exp $
1010
*
1111
* NOTES
1212
* This is used both by the backend and by libpq, but should not be
@@ -261,6 +261,17 @@ typedef struct pg_enc2name
261261

262262
extern pg_enc2name pg_enc2name_tbl[];
263263

264+
/*
265+
* Encoding names for gettext
266+
*/
267+
typedef struct pg_enc2gettext
268+
{
269+
pg_enc encoding;
270+
const char *name;
271+
} pg_enc2gettext;
272+
273+
extern pg_enc2gettext pg_enc2gettext_tbl[];
274+
264275
/*
265276
* pg_wchar stuff
266277
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy