summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-05-14 22:27:07 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-05-14 22:27:12 -0400
commit7730f48ede0d222e7f750541d3d5f0f74d75d99b (patch)
tree472b56a394d55b08d31fcbaa1015d2475c788795
parent83e176ec18d2a91dbea1d0d1bd94c38dc47cd77c (diff)
downloadpostgresql-7730f48ede0d222e7f750541d3d5f0f74d75d99b.tar.gz
Teach UtfToLocal/LocalToUtf to support algorithmic encoding conversions.
Until now, these functions have only supported encoding conversions using lookup tables, which is fine as long as there's not too many code points to convert. However, GB18030 expects all 1.1 million Unicode code points to be convertible, which would require a ridiculously-sized lookup table. Fortunately, a large fraction of those conversions can be expressed through arithmetic, ie the conversions are one-to-one in certain defined ranges. To support that, provide a callback function that is used after consulting the lookup tables. (This patch doesn't actually change anything about the GB18030 conversion behavior, just provide infrastructure for fixing it.) Since this requires changing the APIs of UtfToLocal/LocalToUtf anyway, take the opportunity to rearrange their argument lists into what seems to me a saner order. And beautify the call sites by using lengthof() instead of error-prone sizeof() arithmetic. In passing, also mark all the lookup tables used by these calls "const". This moves an impressive amount of stuff into the text segment, at least on my machine, and is safer anyhow.
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_BIG5.pl4
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl4
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl8
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl4
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl4
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl4
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_GB18030.pl4
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl8
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_SJIS.pl4
-rw-r--r--src/backend/utils/mb/Unicode/UCS_to_most.pl4
-rw-r--r--src/backend/utils/mb/Unicode/big5_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/euc_cn_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8_combined.map2
-rw-r--r--src/backend/utils/mb/Unicode/euc_jp_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/euc_kr_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/euc_tw_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/gb18030_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/gbk_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/johab_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/koi8r_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/koi8u_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8_combined.map2
-rw-r--r--src/backend/utils/mb/Unicode/sjis_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/uhc_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_big5.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_euc_cn.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004_combined.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_euc_jp.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_euc_kr.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_euc_tw.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_gb18030.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_gbk.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_10.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_13.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_14.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_15.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_16.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_2.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_3.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_4.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_5.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_6.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_7.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_8.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_iso8859_9.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_johab.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_koi8r.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_koi8u.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004_combined.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_sjis.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_uhc.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1250.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1251.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1252.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1253.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1254.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1255.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1256.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1257.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win1258.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win866.map2
-rw-r--r--src/backend/utils/mb/Unicode/utf8_to_win874.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1250_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1251_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1252_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1253_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1254_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1255_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1256_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1257_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win1258_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win866_to_utf8.map2
-rw-r--r--src/backend/utils/mb/Unicode/win874_to_utf8.map2
-rw-r--r--src/backend/utils/mb/conv.c327
-rw-r--r--src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c28
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c18
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c80
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c18
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c72
-rw-r--r--src/include/mb/pg_wchar.h41
108 files changed, 538 insertions, 408 deletions
diff --git a/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl b/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
index c741d6e703..bd479298ec 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
@@ -97,7 +97,7 @@ close(FILE);
$file = lc("utf8_to_big5.map");
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapBIG5[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapBIG5[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -185,7 +185,7 @@ close(FILE);
$file = lc("big5_to_utf8.map");
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapBIG5[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapBIG5[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
index cb9a8cb003..bfc99123bf 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
@@ -55,7 +55,7 @@ close(FILE);
$file = "utf8_to_euc_cn.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapEUC_CN[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapEUC_CN[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -109,7 +109,7 @@ close(FILE);
$file = "euc_cn_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapEUC_CN[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapEUC_CN[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
index 67962e39d2..7860736b3b 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
@@ -72,7 +72,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
-print FILE "static pg_utf_to_local ULmapEUC_JIS_2004[] = {\n";
+print FILE "static const pg_utf_to_local ULmapEUC_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -133,7 +133,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE
- "static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {\n";
+ "static const pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {\n";
for $index (sort { $a cmp $b } keys(%array1))
{
@@ -256,7 +256,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
-print FILE "static pg_local_to_utf LUmapEUC_JIS_2004[] = {\n";
+print FILE "static const pg_local_to_utf LUmapEUC_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -283,7 +283,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE
- "static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {\n";
+ "static const pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {\n";
for $index (sort { $a <=> $b } keys(%array1))
{
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
index c2297e5d67..79bc05b4bb 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
@@ -136,7 +136,7 @@ close(FILE);
$file = "utf8_to_euc_jp.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapEUC_JP[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapEUC_JP[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -263,7 +263,7 @@ close(FILE);
$file = "euc_jp_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapEUC_JP[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapEUC_JP[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
index 42cd20028c..fa553fdafa 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
@@ -55,7 +55,7 @@ close(FILE);
$file = "utf8_to_euc_kr.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapEUC_KR[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapEUC_KR[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -109,7 +109,7 @@ close(FILE);
$file = "euc_kr_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
index 1d76f135e6..02414ba202 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
@@ -71,7 +71,7 @@ close(FILE);
$file = "utf8_to_euc_tw.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapEUC_TW[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapEUC_TW[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -138,7 +138,7 @@ close(FILE);
$file = "euc_tw_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapEUC_TW[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapEUC_TW[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl b/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
index 4f0bd078f7..259cb5d9dd 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
@@ -52,7 +52,7 @@ close(FILE);
$file = "utf8_to_gb18030.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapGB18030[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapGB18030[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -106,7 +106,7 @@ close(FILE);
$file = "gb18030_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapGB18030[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapGB18030[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl b/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
index 1a367d71a3..edfb61bcd9 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
@@ -72,7 +72,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
-print FILE "static pg_utf_to_local ULmapSHIFT_JIS_2004[] = {\n";
+print FILE "static const pg_utf_to_local ULmapSHIFT_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -99,7 +99,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE
- "static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {\n";
+ "static const pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {\n";
for $index (sort { $a cmp $b } keys(%array1))
{
@@ -185,7 +185,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFTJIS_2004.pl\n";
print FILE " */\n";
-print FILE "static pg_local_to_utf LUmapSHIFT_JIS_2004[] = {\n";
+print FILE "static const pg_local_to_utf LUmapSHIFT_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -212,7 +212,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE
- "static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n";
+ "static const pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n";
for $index (sort { $a <=> $b } keys(%array1))
{
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
index 6659798996..74cd7ac5f8 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
@@ -72,7 +72,7 @@ close(FILE);
$file = "utf8_to_sjis.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_utf_to_local ULmapSJIS[ $count ] = {\n";
+print FILE "static const pg_utf_to_local ULmapSJIS[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -122,7 +122,7 @@ close(FILE);
$file = "sjis_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
-print FILE "static pg_local_to_utf LUmapSJIS[ $count ] = {\n";
+print FILE "static const pg_local_to_utf LUmapSJIS[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/UCS_to_most.pl b/src/backend/utils/mb/Unicode/UCS_to_most.pl
index 9c8e39b9e5..94e13fa241 100644
--- a/src/backend/utils/mb/Unicode/UCS_to_most.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_most.pl
@@ -88,7 +88,7 @@ foreach $charset (@charsets)
$file = lc("utf8_to_${charset}.map");
open(FILE, "> $file") || die("cannot open $file");
- print FILE "static pg_utf_to_local ULmap${charset}[ $count ] = {\n";
+ print FILE "static const pg_utf_to_local ULmap${charset}[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
@@ -140,7 +140,7 @@ foreach $charset (@charsets)
$file = lc("${charset}_to_utf8.map");
open(FILE, "> $file") || die("cannot open $file");
- print FILE "static pg_local_to_utf LUmap${charset}[ $count ] = {\n";
+ print FILE "static const pg_local_to_utf LUmap${charset}[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
diff --git a/src/backend/utils/mb/Unicode/big5_to_utf8.map b/src/backend/utils/mb/Unicode/big5_to_utf8.map
index cf180b61cd..8d6dbd2a35 100644
--- a/src/backend/utils/mb/Unicode/big5_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/big5_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapBIG5[ 13717 ] = {
+static const pg_local_to_utf LUmapBIG5[ 13717 ] = {
{0xa140, 0xe38080},
{0xa141, 0xefbc8c},
{0xa142, 0xe38081},
diff --git a/src/backend/utils/mb/Unicode/euc_cn_to_utf8.map b/src/backend/utils/mb/Unicode/euc_cn_to_utf8.map
index bd12ebe39b..4052379832 100644
--- a/src/backend/utils/mb/Unicode/euc_cn_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/euc_cn_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/euc_cn_to_utf8.map */
-static pg_local_to_utf LUmapEUC_CN[ 7445 ] = {
+static const pg_local_to_utf LUmapEUC_CN[ 7445 ] = {
{0xa1a1, 0xe38080},
{0xa1a2, 0xe38081},
{0xa1a3, 0xe38082},
diff --git a/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8.map b/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8.map
index d81b00b46a..5095929752 100644
--- a/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
-static pg_local_to_utf LUmapEUC_JIS_2004[] = {
+static const pg_local_to_utf LUmapEUC_JIS_2004[] = {
{0x000000, 0x00000000}, /* U+0000 <control> */
{0x000001, 0x00000001}, /* U+0001 <control> */
{0x000002, 0x00000002}, /* U+0002 <control> */
diff --git a/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8_combined.map b/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8_combined.map
index 318c26f2ba..fb4b247772 100644
--- a/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8_combined.map
+++ b/src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8_combined.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
-static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {
+static const pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {
{0x00a4f7, 0x00e3818b, 0x00e3829a}, /* U+304B+309A [2000] */
{0x00a4f8, 0x00e3818d, 0x00e3829a}, /* U+304D+309A [2000] */
{0x00a4f9, 0x00e3818f, 0x00e3829a}, /* U+304F+309A [2000] */
diff --git a/src/backend/utils/mb/Unicode/euc_jp_to_utf8.map b/src/backend/utils/mb/Unicode/euc_jp_to_utf8.map
index ae796c12c2..db427cbb24 100644
--- a/src/backend/utils/mb/Unicode/euc_jp_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/euc_jp_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/euc_jp_to_utf8.map */
-static pg_local_to_utf LUmapEUC_JP[] = {
+static const pg_local_to_utf LUmapEUC_JP[] = {
{0x8ea1, 0xefbda1},
{0x8ea2, 0xefbda2},
{0x8ea3, 0xefbda3},
diff --git a/src/backend/utils/mb/Unicode/euc_kr_to_utf8.map b/src/backend/utils/mb/Unicode/euc_kr_to_utf8.map
index c3283be6fc..e37152137d 100644
--- a/src/backend/utils/mb/Unicode/euc_kr_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/euc_kr_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapEUC_KR[ 8227 ] = {
+static const pg_local_to_utf LUmapEUC_KR[ 8227 ] = {
{0xa1a1, 0xe38080},
{0xa1a2, 0xe38081},
{0xa1a3, 0xe38082},
diff --git a/src/backend/utils/mb/Unicode/euc_tw_to_utf8.map b/src/backend/utils/mb/Unicode/euc_tw_to_utf8.map
index d3a303f64b..b430b446dd 100644
--- a/src/backend/utils/mb/Unicode/euc_tw_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/euc_tw_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/euc_tw_to_utf8.map */
-static pg_local_to_utf LUmapEUC_TW[ 23575 ] = {
+static const pg_local_to_utf LUmapEUC_TW[ 23575 ] = {
{0xa1a1, 0xe38080},
{0xa1a2, 0xefbc8c},
{0xa1a3, 0xe38081},
diff --git a/src/backend/utils/mb/Unicode/gb18030_to_utf8.map b/src/backend/utils/mb/Unicode/gb18030_to_utf8.map
index 95669451d2..1715f6dd53 100644
--- a/src/backend/utils/mb/Unicode/gb18030_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/gb18030_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/gb18030_to_utf8.map */
-static pg_local_to_utf LUmapGB18030[ 63360 ] = {
+static const pg_local_to_utf LUmapGB18030[ 63360 ] = {
{0x8140, 0xe4b882},
{0x8141, 0xe4b884},
{0x8142, 0xe4b885},
diff --git a/src/backend/utils/mb/Unicode/gbk_to_utf8.map b/src/backend/utils/mb/Unicode/gbk_to_utf8.map
index 6804f5dc69..fced1f4590 100644
--- a/src/backend/utils/mb/Unicode/gbk_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/gbk_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/gbk_to_utf8.map */
-static pg_local_to_utf LUmapGBK[ 21792 ] = {
+static const pg_local_to_utf LUmapGBK[ 21792 ] = {
{0x0080, 0xe282ac},
{0x8140, 0xe4b882},
{0x8141, 0xe4b884},
diff --git a/src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map
index 607b8e9401..8a650ee5e7 100644
--- a/src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_10[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_10[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map
index d50ce084f0..207570635d 100644
--- a/src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_13[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_13[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map
index eaecef88e8..49d63d4f07 100644
--- a/src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_14[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_14[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map
index e11a6bd241..349b64cbda 100644
--- a/src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_15[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_15[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map
index 77382cb7ed..d8e280166c 100644
--- a/src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_16[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_16[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map
index 5cc984470d..30d487a0c0 100644
--- a/src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_2[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_2[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map
index 2a7e285597..94b5bc4f20 100644
--- a/src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_3[ 121 ] = {
+static const pg_local_to_utf LUmapISO8859_3[ 121 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map
index 315f1d3be6..f339c1991f 100644
--- a/src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_4[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_4[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map
index 60838e1be7..601be303e0 100644
--- a/src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_5[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_5[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map
index f097a01bf5..289f97e7b5 100644
--- a/src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_6[ 83 ] = {
+static const pg_local_to_utf LUmapISO8859_6[ 83 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map
index 8cc6826a79..fbbecaa340 100644
--- a/src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_7[ 125 ] = {
+static const pg_local_to_utf LUmapISO8859_7[ 125 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map
index 22e0b4e266..4ed316c789 100644
--- a/src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_8[ 92 ] = {
+static const pg_local_to_utf LUmapISO8859_8[ 92 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map b/src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map
index 268f0e4c93..f86cc65129 100644
--- a/src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map */
-static pg_local_to_utf LUmapISO8859_9[ 128 ] = {
+static const pg_local_to_utf LUmapISO8859_9[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
diff --git a/src/backend/utils/mb/Unicode/johab_to_utf8.map b/src/backend/utils/mb/Unicode/johab_to_utf8.map
index a4584c5bc5..8110f6e853 100644
--- a/src/backend/utils/mb/Unicode/johab_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/johab_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapJOHAB[ 17049 ] = {
+static const pg_local_to_utf LUmapJOHAB[ 17049 ] = {
{0x8444, 0xe384b3},
{0x8446, 0xe384b5},
{0x8447, 0xe384b6},
diff --git a/src/backend/utils/mb/Unicode/koi8r_to_utf8.map b/src/backend/utils/mb/Unicode/koi8r_to_utf8.map
index 9364e5efe9..738f160bfa 100644
--- a/src/backend/utils/mb/Unicode/koi8r_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/koi8r_to_utf8.map
@@ -1,6 +1,6 @@
/* src/backend/utils/mb/Unicode/koi8r_to_utf8.map */
-static pg_local_to_utf LUmapKOI8R[ 128 ] = {
+static const pg_local_to_utf LUmapKOI8R[ 128 ] = {
{0x0080, 0xe29480},
{0x0081, 0xe29482},
{0x0082, 0xe2948c},
diff --git a/src/backend/utils/mb/Unicode/koi8u_to_utf8.map b/src/backend/utils/mb/Unicode/koi8u_to_utf8.map
index 659f4868e5..087ad4a5f5 100644
--- a/src/backend/utils/mb/Unicode/koi8u_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/koi8u_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapKOI8U[ 128 ] = {
+static const pg_local_to_utf LUmapKOI8U[ 128 ] = {
{0x0080, 0xe29480},
{0x0081, 0xe29482},
{0x0082, 0xe2948c},
diff --git a/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8.map b/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8.map
index 5a1496c88c..f2b268acd3 100644
--- a/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_SHIFTJIS_2004.pl
*/
-static pg_local_to_utf LUmapSHIFT_JIS_2004[] = {
+static const pg_local_to_utf LUmapSHIFT_JIS_2004[] = {
{0x0000, 0x00000000}, /* U+0000 <control> */
{0x0001, 0x00000001}, /* U+0001 <control> */
{0x0002, 0x00000002}, /* U+0002 <control> */
diff --git a/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8_combined.map b/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8_combined.map
index 57d54c9f09..b1c7bced5f 100644
--- a/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8_combined.map
+++ b/src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8_combined.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_SHIFT_JIS_2004.pl
*/
-static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {
+static const pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {
{0x82f5, 0x00e3818b, 0x00e3829a}, /* U+304B+309A [2000] */
{0x82f6, 0x00e3818d, 0x00e3829a}, /* U+304D+309A [2000] */
{0x82f7, 0x00e3818f, 0x00e3829a}, /* U+304F+309A [2000] */
diff --git a/src/backend/utils/mb/Unicode/sjis_to_utf8.map b/src/backend/utils/mb/Unicode/sjis_to_utf8.map
index 05e846177b..6bafaa330f 100644
--- a/src/backend/utils/mb/Unicode/sjis_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/sjis_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapSJIS[ 7787 ] = {
+static const pg_local_to_utf LUmapSJIS[ 7787 ] = {
{0x00a1, 0xefbda1},
{0x00a2, 0xefbda2},
{0x00a3, 0xefbda3},
diff --git a/src/backend/utils/mb/Unicode/uhc_to_utf8.map b/src/backend/utils/mb/Unicode/uhc_to_utf8.map
index 47bcfec53b..26a7b18f65 100644
--- a/src/backend/utils/mb/Unicode/uhc_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/uhc_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapUHC[ 17237 ] = {
+static const pg_local_to_utf LUmapUHC[ 17237 ] = {
{0x8141, 0xeab082},
{0x8142, 0xeab083},
{0x8143, 0xeab085},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_big5.map b/src/backend/utils/mb/Unicode/utf8_to_big5.map
index 85b3c24f1d..68cccf441c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_big5.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_big5.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapBIG5[ 13711 ] = {
+static const pg_utf_to_local ULmapBIG5[ 13711 ] = {
{0xc2a2, 0xa246},
{0xc2a3, 0xa247},
{0xc2a5, 0xa244},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_euc_cn.map b/src/backend/utils/mb/Unicode/utf8_to_euc_cn.map
index 949bade3eb..b28eb9cc0c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_euc_cn.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_euc_cn.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapEUC_CN[ 7445 ] = {
+static const pg_utf_to_local ULmapEUC_CN[ 7445 ] = {
{0xc2a4, 0xa1e8},
{0xc2a7, 0xa1ec},
{0xc2a8, 0xa1a7},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004.map b/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004.map
index b51589cd6e..250771f19b 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
-static pg_utf_to_local ULmapEUC_JIS_2004[] = {
+static const pg_utf_to_local ULmapEUC_JIS_2004[] = {
{0x00000000, 0x000000}, /* U+0000 <control> */
{0x00000001, 0x000001}, /* U+0001 <control> */
{0x00000002, 0x000002}, /* U+0002 <control> */
diff --git a/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004_combined.map b/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004_combined.map
index c26cc8d701..d098e256df 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004_combined.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004_combined.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
-static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {
+static const pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {
{0x0000c3a6, 0x0000cc80, 0x00abc4}, /* U+00E6+0300 [2000] */
{0x0000c994, 0x0000cc80, 0x00abc8}, /* U+0254+0300 [2000] */
{0x0000c994, 0x0000cc81, 0x00abc9}, /* U+0254+0301 [2000] */
diff --git a/src/backend/utils/mb/Unicode/utf8_to_euc_jp.map b/src/backend/utils/mb/Unicode/utf8_to_euc_jp.map
index a5b0944440..137d4fdef6 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_euc_jp.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_euc_jp.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapEUC_JP[ 13175 ] = {
+static const pg_utf_to_local ULmapEUC_JP[ 13175 ] = {
{0xc2a1, 0x8fa2c2},
{0xc2a4, 0x8fa2f0},
{0xc2a6, 0x8fa2c3},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_euc_kr.map b/src/backend/utils/mb/Unicode/utf8_to_euc_kr.map
index f5c9d0ab8b..4a78b260ea 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_euc_kr.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_euc_kr.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapEUC_KR[ 8227 ] = {
+static const pg_utf_to_local ULmapEUC_KR[ 8227 ] = {
{0xc2a1, 0xa2ae},
{0xc2a4, 0xa2b4},
{0xc2a7, 0xa1d7},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_euc_tw.map b/src/backend/utils/mb/Unicode/utf8_to_euc_tw.map
index 3ddf9a0176..0ade01aa88 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_euc_tw.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_euc_tw.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapEUC_TW[ 17711 ] = {
+static const pg_utf_to_local ULmapEUC_TW[ 17711 ] = {
{0xc2a7, 0xa1f0},
{0xc2b0, 0xa2f8},
{0xc2b1, 0xa2b4},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_gb18030.map b/src/backend/utils/mb/Unicode/utf8_to_gb18030.map
index 476625b22b..52d380c5c1 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_gb18030.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_gb18030.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapGB18030[ 63360 ] = {
+static const pg_utf_to_local ULmapGB18030[ 63360 ] = {
{0xc280, 0x81308130},
{0xc281, 0x81308131},
{0xc282, 0x81308132},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_gbk.map b/src/backend/utils/mb/Unicode/utf8_to_gbk.map
index df7c4e2a9e..70febd7b2c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_gbk.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_gbk.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapGBK[ 21792 ] = {
+static const pg_utf_to_local ULmapGBK[ 21792 ] = {
{0xc2a4, 0xa1e8},
{0xc2a7, 0xa1ec},
{0xc2a8, 0xa1a7},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_10.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_10.map
index b4aeafee2b..85bbd23cea 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_10.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_10.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_10[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_10[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_13.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_13.map
index eca3784924..24588af340 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_13.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_13.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_13[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_13[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_14.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_14.map
index bef24578ea..8f27305086 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_14.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_14.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_14[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_14[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_15.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_15.map
index e1e098865c..f314021b9c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_15.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_15.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_15[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_15[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_16.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_16.map
index 63ba6bdafa..6a8c754bc0 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_16.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_16.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_16[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_16[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_2.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_2.map
index 85ff468e84..8e65a6a4af 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_2.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_2.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_2[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_2[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_3.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_3.map
index e1eced40db..8d0242dd15 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_3.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_3.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_3[ 121 ] = {
+static const pg_utf_to_local ULmapISO8859_3[ 121 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_4.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_4.map
index a621c5a7c4..30fe4f3a50 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_4.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_4.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_4[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_4[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_5.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_5.map
index 524c585bb6..6509d7f6eb 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_5.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_5.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_5[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_5[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_6.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_6.map
index 291f7cf5da..8f29f26ffe 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_6.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_6.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_6[ 83 ] = {
+static const pg_utf_to_local ULmapISO8859_6[ 83 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_7.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_7.map
index 8e4b7d0eb0..b0488ec3e0 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_7.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_7.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_7[ 125 ] = {
+static const pg_utf_to_local ULmapISO8859_7[ 125 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_8.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_8.map
index 62095e54f4..7f31c5dee9 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_8.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_8.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_8[ 92 ] = {
+static const pg_utf_to_local ULmapISO8859_8[ 92 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_iso8859_9.map b/src/backend/utils/mb/Unicode/utf8_to_iso8859_9.map
index baff0f0319..d34b8afcf2 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_iso8859_9.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_iso8859_9.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapISO8859_9[ 128 ] = {
+static const pg_utf_to_local ULmapISO8859_9[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_johab.map b/src/backend/utils/mb/Unicode/utf8_to_johab.map
index 5469f1280b..869f8213d2 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_johab.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_johab.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapJOHAB[ 17049 ] = {
+static const pg_utf_to_local ULmapJOHAB[ 17049 ] = {
{0xc2a1, 0xd9ae},
{0xc2a4, 0xd9b4},
{0xc2a7, 0xd967},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_koi8r.map b/src/backend/utils/mb/Unicode/utf8_to_koi8r.map
index 97ab485e19..b4760da43c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_koi8r.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_koi8r.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapKOI8R[ 128 ] = {
+static const pg_utf_to_local ULmapKOI8R[ 128 ] = {
{0xc2a0, 0x009a},
{0xc2a9, 0x00bf},
{0xc2b0, 0x009c},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_koi8u.map b/src/backend/utils/mb/Unicode/utf8_to_koi8u.map
index 7f262a4aaa..b6366e8718 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_koi8u.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_koi8u.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapKOI8U[ 128 ] = {
+static const pg_utf_to_local ULmapKOI8U[ 128 ] = {
{0xc2a0, 0x009a},
{0xc2a9, 0x00bf},
{0xc2b0, 0x009c},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004.map b/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004.map
index 2c52d4b574..2db1902f58 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_SHIFT_JIS_2004.pl
*/
-static pg_utf_to_local ULmapSHIFT_JIS_2004[] = {
+static const pg_utf_to_local ULmapSHIFT_JIS_2004[] = {
{0x00000000, 0x000000}, /* U+0000 <control> */
{0x00000001, 0x000001}, /* U+0001 <control> */
{0x00000002, 0x000002}, /* U+0002 <control> */
diff --git a/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004_combined.map b/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004_combined.map
index c6502e3a8e..e55d4a2a6c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004_combined.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004_combined.map
@@ -1,7 +1,7 @@
/*
* This file was generated by UCS_to_SHIFT_JIS_2004.pl
*/
-static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {
+static const pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {
{0x0000c3a6, 0x0000cc80, 0x8663}, /* U+00E6+0300 [2000] */
{0x0000c994, 0x0000cc80, 0x8667}, /* U+0254+0300 [2000] */
{0x0000c994, 0x0000cc81, 0x8668}, /* U+0254+0301 [2000] */
diff --git a/src/backend/utils/mb/Unicode/utf8_to_sjis.map b/src/backend/utils/mb/Unicode/utf8_to_sjis.map
index d827ae5c26..bcb76c9150 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_sjis.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_sjis.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapSJIS[ 7398 ] = {
+static const pg_utf_to_local ULmapSJIS[ 7398 ] = {
{0xc19c, 0x815f},
{0xc2a2, 0x8191},
{0xc2a3, 0x8192},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_uhc.map b/src/backend/utils/mb/Unicode/utf8_to_uhc.map
index e252eecc09..15dfb56a09 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_uhc.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_uhc.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapUHC[ 17237 ] = {
+static const pg_utf_to_local ULmapUHC[ 17237 ] = {
{0xc2a1, 0xa2ae},
{0xc2a4, 0xa2b4},
{0xc2a7, 0xa1d7},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1250.map b/src/backend/utils/mb/Unicode/utf8_to_win1250.map
index ef0381dc43..4dd4631ab8 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1250.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1250.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1250[ 123 ] = {
+static const pg_utf_to_local ULmapWIN1250[ 123 ] = {
{0xc2a0, 0x00a0},
{0xc2a4, 0x00a4},
{0xc2a6, 0x00a6},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1251.map b/src/backend/utils/mb/Unicode/utf8_to_win1251.map
index e69fd6573e..3dc9f2b5e3 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1251.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1251.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1251[ 127 ] = {
+static const pg_utf_to_local ULmapWIN1251[ 127 ] = {
{0xc2a0, 0x00a0},
{0xc2a4, 0x00a4},
{0xc2a6, 0x00a6},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1252.map b/src/backend/utils/mb/Unicode/utf8_to_win1252.map
index ba9594b74c..bc460a340b 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1252.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1252.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1252[ 123 ] = {
+static const pg_utf_to_local ULmapWIN1252[ 123 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1253.map b/src/backend/utils/mb/Unicode/utf8_to_win1253.map
index a7961e95f1..4cf0330136 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1253.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1253.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1253[ 111 ] = {
+static const pg_utf_to_local ULmapWIN1253[ 111 ] = {
{0xc2a0, 0x00a0},
{0xc2a3, 0x00a3},
{0xc2a4, 0x00a4},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1254.map b/src/backend/utils/mb/Unicode/utf8_to_win1254.map
index e1afbe8f40..54f1e0fe4c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1254.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1254.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1254[ 121 ] = {
+static const pg_utf_to_local ULmapWIN1254[ 121 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1255.map b/src/backend/utils/mb/Unicode/utf8_to_win1255.map
index 9071fe0a61..328f0a1293 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1255.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1255.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1255[ 105 ] = {
+static const pg_utf_to_local ULmapWIN1255[ 105 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1256.map b/src/backend/utils/mb/Unicode/utf8_to_win1256.map
index 1ae675f791..aa7d36a18e 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1256.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1256.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1256[ 128 ] = {
+static const pg_utf_to_local ULmapWIN1256[ 128 ] = {
{0xc2a0, 0x00a0},
{0xc2a2, 0x00a2},
{0xc2a3, 0x00a3},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1257.map b/src/backend/utils/mb/Unicode/utf8_to_win1257.map
index 562678119e..dca28d28ae 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1257.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1257.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1257[ 116 ] = {
+static const pg_utf_to_local ULmapWIN1257[ 116 ] = {
{0xc2a0, 0x00a0},
{0xc2a2, 0x00a2},
{0xc2a3, 0x00a3},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win1258.map b/src/backend/utils/mb/Unicode/utf8_to_win1258.map
index 7c4629ff91..371e315bdb 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win1258.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win1258.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN1258[ 119 ] = {
+static const pg_utf_to_local ULmapWIN1258[ 119 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win866.map b/src/backend/utils/mb/Unicode/utf8_to_win866.map
index e5767e0930..dbd705b96c 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win866.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win866.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN866[ 128 ] = {
+static const pg_utf_to_local ULmapWIN866[ 128 ] = {
{0xc2a0, 0x00ff},
{0xc2a4, 0x00fd},
{0xc2b0, 0x00f8},
diff --git a/src/backend/utils/mb/Unicode/utf8_to_win874.map b/src/backend/utils/mb/Unicode/utf8_to_win874.map
index d765744461..9265a39f4e 100644
--- a/src/backend/utils/mb/Unicode/utf8_to_win874.map
+++ b/src/backend/utils/mb/Unicode/utf8_to_win874.map
@@ -1,4 +1,4 @@
-static pg_utf_to_local ULmapWIN874[ 97 ] = {
+static const pg_utf_to_local ULmapWIN874[ 97 ] = {
{0xc2a0, 0x00a0},
{0xe0b881, 0x00a1},
{0xe0b882, 0x00a2},
diff --git a/src/backend/utils/mb/Unicode/win1250_to_utf8.map b/src/backend/utils/mb/Unicode/win1250_to_utf8.map
index 22f44b7f58..dd44dceafc 100644
--- a/src/backend/utils/mb/Unicode/win1250_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1250_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1250[ 123 ] = {
+static const pg_local_to_utf LUmapWIN1250[ 123 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0084, 0xe2809e},
diff --git a/src/backend/utils/mb/Unicode/win1251_to_utf8.map b/src/backend/utils/mb/Unicode/win1251_to_utf8.map
index cdea6fe445..a4f1aeb49d 100644
--- a/src/backend/utils/mb/Unicode/win1251_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1251_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1251[ 127 ] = {
+static const pg_local_to_utf LUmapWIN1251[ 127 ] = {
{0x0080, 0xd082},
{0x0081, 0xd083},
{0x0082, 0xe2809a},
diff --git a/src/backend/utils/mb/Unicode/win1252_to_utf8.map b/src/backend/utils/mb/Unicode/win1252_to_utf8.map
index ad849ee011..7b547becc8 100644
--- a/src/backend/utils/mb/Unicode/win1252_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1252_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1252[ 123 ] = {
+static const pg_local_to_utf LUmapWIN1252[ 123 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
diff --git a/src/backend/utils/mb/Unicode/win1253_to_utf8.map b/src/backend/utils/mb/Unicode/win1253_to_utf8.map
index 519a435d75..d22b72f23f 100644
--- a/src/backend/utils/mb/Unicode/win1253_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1253_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1253[ 111 ] = {
+static const pg_local_to_utf LUmapWIN1253[ 111 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
diff --git a/src/backend/utils/mb/Unicode/win1254_to_utf8.map b/src/backend/utils/mb/Unicode/win1254_to_utf8.map
index 370e4bc910..3eff3d657a 100644
--- a/src/backend/utils/mb/Unicode/win1254_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1254_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1254[ 121 ] = {
+static const pg_local_to_utf LUmapWIN1254[ 121 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
diff --git a/src/backend/utils/mb/Unicode/win1255_to_utf8.map b/src/backend/utils/mb/Unicode/win1255_to_utf8.map
index f5d7454c29..5be6b63e08 100644
--- a/src/backend/utils/mb/Unicode/win1255_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1255_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1255[ 105 ] = {
+static const pg_local_to_utf LUmapWIN1255[ 105 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
diff --git a/src/backend/utils/mb/Unicode/win1256_to_utf8.map b/src/backend/utils/mb/Unicode/win1256_to_utf8.map
index edf3ae9de3..a61aa45ec2 100644
--- a/src/backend/utils/mb/Unicode/win1256_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1256_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1256[ 128 ] = {
+static const pg_local_to_utf LUmapWIN1256[ 128 ] = {
{0x0080, 0xe282ac},
{0x0081, 0xd9be},
{0x0082, 0xe2809a},
diff --git a/src/backend/utils/mb/Unicode/win1257_to_utf8.map b/src/backend/utils/mb/Unicode/win1257_to_utf8.map
index 45d946d57c..134f9726a8 100644
--- a/src/backend/utils/mb/Unicode/win1257_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1257_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1257[ 116 ] = {
+static const pg_local_to_utf LUmapWIN1257[ 116 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0084, 0xe2809e},
diff --git a/src/backend/utils/mb/Unicode/win1258_to_utf8.map b/src/backend/utils/mb/Unicode/win1258_to_utf8.map
index ed8a9146fc..5807d112dc 100644
--- a/src/backend/utils/mb/Unicode/win1258_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win1258_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN1258[ 119 ] = {
+static const pg_local_to_utf LUmapWIN1258[ 119 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
diff --git a/src/backend/utils/mb/Unicode/win866_to_utf8.map b/src/backend/utils/mb/Unicode/win866_to_utf8.map
index d2a377a537..411c043b27 100644
--- a/src/backend/utils/mb/Unicode/win866_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win866_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN866[ 128 ] = {
+static const pg_local_to_utf LUmapWIN866[ 128 ] = {
{0x0080, 0xd090},
{0x0081, 0xd091},
{0x0082, 0xd092},
diff --git a/src/backend/utils/mb/Unicode/win874_to_utf8.map b/src/backend/utils/mb/Unicode/win874_to_utf8.map
index bd4eadbbb6..1472b0f1e6 100644
--- a/src/backend/utils/mb/Unicode/win874_to_utf8.map
+++ b/src/backend/utils/mb/Unicode/win874_to_utf8.map
@@ -1,4 +1,4 @@
-static pg_local_to_utf LUmapWIN874[ 97 ] = {
+static const pg_local_to_utf LUmapWIN874[ 97 ] = {
{0x0080, 0xe282ac},
{0x0085, 0xe280a6},
{0x0091, 0xe28098},
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index d5c5c74a9c..f957b6efd3 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -302,47 +302,62 @@ compare4(const void *p1, const void *p2)
}
/*
- * convert 32bit wide character to mutibye stream pointed to by iso
+ * store 32bit character representation into multibyte stream
*/
-static unsigned char *
-set_iso_code(unsigned char *iso, uint32 code)
+static inline unsigned char *
+store_coded_char(unsigned char *dest, uint32 code)
{
if (code & 0xff000000)
- *iso++ = code >> 24;
+ *dest++ = code >> 24;
if (code & 0x00ff0000)
- *iso++ = (code & 0x00ff0000) >> 16;
+ *dest++ = code >> 16;
if (code & 0x0000ff00)
- *iso++ = (code & 0x0000ff00) >> 8;
+ *dest++ = code >> 8;
if (code & 0x000000ff)
- *iso++ = code & 0x000000ff;
- return iso;
+ *dest++ = code;
+ return dest;
}
/*
* UTF8 ---> local code
*
- * utf: input UTF8 string (need not be null-terminated).
+ * utf: input string in UTF8 encoding (need not be null-terminated)
+ * len: length of input string (in bytes)
* iso: pointer to the output area (must be large enough!)
- * map: the conversion map.
- * cmap: the conversion map for combined characters.
- * (optional)
- * size1: the size of the conversion map.
- * size2: the size of the conversion map for combined characters
- * (optional)
- * encoding: the PG identifier for the local encoding.
- * len: length of input string.
+ (output string will be null-terminated)
+ * map: conversion map for single characters
+ * mapsize: number of entries in the conversion map
+ * cmap: conversion map for combined characters
+ * (optional, pass NULL if none)
+ * cmapsize: number of entries in the conversion map for combined characters
+ * (optional, pass 0 if none)
+ * conv_func: algorithmic encoding conversion function
+ * (optional, pass NULL if none)
+ * encoding: PG identifier for the local encoding
+ *
+ * For each character, the cmap (if provided) is consulted first; if no match,
+ * the map is consulted next; if still no match, the conv_func (if provided)
+ * is applied. An error is raised if no match is found.
+ *
+ * See pg_wchar.h for more details about the data structures used here.
*/
void
-UtfToLocal(const unsigned char *utf, unsigned char *iso,
- const pg_utf_to_local *map, const pg_utf_to_local_combined *cmap,
- int size1, int size2, int encoding, int len)
+UtfToLocal(const unsigned char *utf, int len,
+ unsigned char *iso,
+ const pg_utf_to_local *map, int mapsize,
+ const pg_utf_to_local_combined *cmap, int cmapsize,
+ utf_local_conversion_func conv_func,
+ int encoding)
{
uint32 iutf;
- uint32 cutf[2];
- uint32 code;
- pg_utf_to_local *p;
- pg_utf_to_local_combined *cp;
int l;
+ const pg_utf_to_local *p;
+ const pg_utf_to_local_combined *cp;
+
+ if (!PG_VALID_ENCODING(encoding))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid encoding number: %d", encoding)));
for (; len > 0; len -= l)
{
@@ -351,7 +366,6 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
break;
l = pg_utf_mblen(utf);
-
if (len < l)
break;
@@ -360,11 +374,13 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
if (l == 1)
{
- /* ASCII case is easy */
+ /* ASCII case is easy, assume it's one-to-one conversion */
*iso++ = *utf++;
continue;
}
- else if (l == 2)
+
+ /* collect coded char of length l */
+ if (l == 2)
{
iutf = *utf++ << 8;
iutf |= *utf++;
@@ -388,15 +404,14 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
iutf = 0; /* keep compiler quiet */
}
- /*
- * first, try with combined map if possible
- */
+ /* First, try with combined map if possible */
if (cmap && len > l)
{
const unsigned char *utf_save = utf;
int len_save = len;
int l_save = l;
+ /* collect next character, same as above */
len -= l;
l = pg_utf_mblen(utf);
@@ -406,83 +421,83 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
if (!pg_utf8_islegal(utf, l))
break;
- cutf[0] = iutf;
-
- if (l == 1)
+ /* We assume ASCII character cannot be in combined map */
+ if (l > 1)
{
- if (len_save > 1)
+ uint32 iutf2;
+ uint32 cutf[2];
+
+ if (l == 2)
+ {
+ iutf2 = *utf++ << 8;
+ iutf2 |= *utf++;
+ }
+ else if (l == 3)
+ {
+ iutf2 = *utf++ << 16;
+ iutf2 |= *utf++ << 8;
+ iutf2 |= *utf++;
+ }
+ else if (l == 4)
+ {
+ iutf2 = *utf++ << 24;
+ iutf2 |= *utf++ << 16;
+ iutf2 |= *utf++ << 8;
+ iutf2 |= *utf++;
+ }
+ else
{
- p = bsearch(&cutf[0], map, size1,
- sizeof(pg_utf_to_local), compare1);
- if (p == NULL)
- report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf_save - l_save), len_save);
- iso = set_iso_code(iso, p->code);
+ elog(ERROR, "unsupported character length %d", l);
+ iutf2 = 0; /* keep compiler quiet */
}
- /* ASCII case is easy */
- *iso++ = *utf++;
- continue;
- }
- else if (l == 2)
- {
- iutf = *utf++ << 8;
- iutf |= *utf++;
- }
- else if (l == 3)
- {
- iutf = *utf++ << 16;
- iutf |= *utf++ << 8;
- iutf |= *utf++;
- }
- else if (l == 4)
- {
- iutf = *utf++ << 24;
- iutf |= *utf++ << 16;
- iutf |= *utf++ << 8;
- iutf |= *utf++;
- }
- else
- {
- elog(ERROR, "unsupported character length %d", l);
- iutf = 0; /* keep compiler quiet */
- }
+ cutf[0] = iutf;
+ cutf[1] = iutf2;
- cutf[1] = iutf;
- cp = bsearch(cutf, cmap, size2,
- sizeof(pg_utf_to_local_combined), compare3);
- if (cp)
- code = cp->code;
- else
- {
- /* not found in combined map. try with ordinary map */
- p = bsearch(&cutf[0], map, size1,
- sizeof(pg_utf_to_local), compare1);
- if (p == NULL)
- report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf_save - l_save), len_save);
- iso = set_iso_code(iso, p->code);
-
- p = bsearch(&cutf[1], map, size1,
- sizeof(pg_utf_to_local), compare1);
- if (p == NULL)
- report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf - l), len);
- code = p->code;
+ cp = bsearch(cutf, cmap, cmapsize,
+ sizeof(pg_utf_to_local_combined), compare3);
+
+ if (cp)
+ {
+ iso = store_coded_char(iso, cp->code);
+ continue;
+ }
}
+
+ /* fail, so back up to reprocess second character next time */
+ utf = utf_save;
+ len = len_save;
+ l = l_save;
}
- else /* no cmap or no remaining data */
+
+ /* Now check ordinary map */
+ p = bsearch(&iutf, map, mapsize,
+ sizeof(pg_utf_to_local), compare1);
+
+ if (p)
{
- p = bsearch(&iutf, map, size1,
- sizeof(pg_utf_to_local), compare1);
- if (p == NULL)
- report_untranslatable_char(PG_UTF8, encoding,
- (const char *) (utf - l), len);
- code = p->code;
+ iso = store_coded_char(iso, p->code);
+ continue;
+ }
+
+ /* if there's a conversion function, try that */
+ if (conv_func)
+ {
+ uint32 converted = (*conv_func) (iutf);
+
+ if (converted)
+ {
+ iso = store_coded_char(iso, converted);
+ continue;
+ }
}
- iso = set_iso_code(iso, code);
+
+ /* failed to translate this character */
+ report_untranslatable_char(PG_UTF8, encoding,
+ (const char *) (utf - l), len);
}
+ /* if we broke out of loop early, must be invalid input */
if (len > 0)
report_invalid_encoding(PG_UTF8, (const char *) utf, len);
@@ -492,26 +507,38 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
/*
* local code ---> UTF8
*
- * iso: input local string (need not be null-terminated).
+ * iso: input string in local encoding (need not be null-terminated)
+ * len: length of input string (in bytes)
* utf: pointer to the output area (must be large enough!)
- * map: the conversion map.
- * cmap: the conversion map for combined characters.
- * (optional)
- * size1: the size of the conversion map.
- * size2: the size of the conversion map for combined characters
- * (optional)
- * encoding: the PG identifier for the local encoding.
- * len: length of input string.
+ (output string will be null-terminated)
+ * map: conversion map for single characters
+ * mapsize: number of entries in the conversion map
+ * cmap: conversion map for combined characters
+ * (optional, pass NULL if none)
+ * cmapsize: number of entries in the conversion map for combined characters
+ * (optional, pass 0 if none)
+ * conv_func: algorithmic encoding conversion function
+ * (optional, pass NULL if none)
+ * encoding: PG identifier for the local encoding
+ *
+ * For each character, the map is consulted first; if no match, the cmap
+ * (if provided) is consulted next; if still no match, the conv_func
+ * (if provided) is applied. An error is raised if no match is found.
+ *
+ * See pg_wchar.h for more details about the data structures used here.
*/
void
-LocalToUtf(const unsigned char *iso, unsigned char *utf,
- const pg_local_to_utf *map, const pg_local_to_utf_combined *cmap,
- int size1, int size2, int encoding, int len)
+LocalToUtf(const unsigned char *iso, int len,
+ unsigned char *utf,
+ const pg_local_to_utf *map, int mapsize,
+ const pg_local_to_utf_combined *cmap, int cmapsize,
+ utf_local_conversion_func conv_func,
+ int encoding)
{
- unsigned int iiso;
+ uint32 iiso;
int l;
- pg_local_to_utf *p;
- pg_local_to_utf_combined *cp;
+ const pg_local_to_utf *p;
+ const pg_local_to_utf_combined *cp;
if (!PG_VALID_ENCODING(encoding))
ereport(ERROR,
@@ -526,7 +553,7 @@ LocalToUtf(const unsigned char *iso, unsigned char *utf,
if (!IS_HIGHBIT_SET(*iso))
{
- /* ASCII case is easy */
+ /* ASCII case is easy, assume it's one-to-one conversion */
*utf++ = *iso++;
l = 1;
continue;
@@ -536,6 +563,7 @@ LocalToUtf(const unsigned char *iso, unsigned char *utf,
if (l < 0)
break;
+ /* collect coded char of length l */
if (l == 1)
iiso = *iso++;
else if (l == 2)
@@ -562,61 +590,48 @@ LocalToUtf(const unsigned char *iso, unsigned char *utf,
iiso = 0; /* keep compiler quiet */
}
- p = bsearch(&iiso, map, size1,
+ /* First check ordinary map */
+ p = bsearch(&iiso, map, mapsize,
sizeof(pg_local_to_utf), compare2);
- if (p == NULL)
+ if (p)
{
- /*
- * not found in the ordinary map. if there's a combined character
- * map, try with it
- */
- if (cmap)
- {
- cp = bsearch(&iiso, cmap, size2,
- sizeof(pg_local_to_utf_combined), compare4);
+ utf = store_coded_char(utf, p->utf);
+ continue;
+ }
- if (cp)
- {
- if (cp->utf1 & 0xff000000)
- *utf++ = cp->utf1 >> 24;
- if (cp->utf1 & 0x00ff0000)
- *utf++ = (cp->utf1 & 0x00ff0000) >> 16;
- if (cp->utf1 & 0x0000ff00)
- *utf++ = (cp->utf1 & 0x0000ff00) >> 8;
- if (cp->utf1 & 0x000000ff)
- *utf++ = cp->utf1 & 0x000000ff;
-
- if (cp->utf2 & 0xff000000)
- *utf++ = cp->utf2 >> 24;
- if (cp->utf2 & 0x00ff0000)
- *utf++ = (cp->utf2 & 0x00ff0000) >> 16;
- if (cp->utf2 & 0x0000ff00)
- *utf++ = (cp->utf2 & 0x0000ff00) >> 8;
- if (cp->utf2 & 0x000000ff)
- *utf++ = cp->utf2 & 0x000000ff;
+ /* If there's a combined character map, try that */
+ if (cmap)
+ {
+ cp = bsearch(&iiso, cmap, cmapsize,
+ sizeof(pg_local_to_utf_combined), compare4);
- continue;
- }
+ if (cp)
+ {
+ utf = store_coded_char(utf, cp->utf1);
+ utf = store_coded_char(utf, cp->utf2);
+ continue;
}
-
- report_untranslatable_char(encoding, PG_UTF8,
- (const char *) (iso - l), len);
-
}
- else
+
+ /* if there's a conversion function, try that */
+ if (conv_func)
{
- if (p->utf & 0xff000000)
- *utf++ = p->utf >> 24;
- if (p->utf & 0x00ff0000)
- *utf++ = (p->utf & 0x00ff0000) >> 16;
- if (p->utf & 0x0000ff00)
- *utf++ = (p->utf & 0x0000ff00) >> 8;
- if (p->utf & 0x000000ff)
- *utf++ = p->utf & 0x000000ff;
+ uint32 converted = (*conv_func) (iiso);
+
+ if (converted)
+ {
+ utf = store_coded_char(utf, converted);
+ continue;
+ }
}
+
+ /* failed to translate this character */
+ report_untranslatable_char(encoding, PG_UTF8,
+ (const char *) (iso - l), len);
}
+ /* if we broke out of loop early, must be invalid input */
if (len > 0)
report_invalid_encoding(encoding, (const char *) iso, len);
diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
index 6861572655..1d9b10f8a7 100644
--- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
+++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
@@ -22,7 +22,7 @@ typedef struct
} codes_t;
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
-static codes_t big5Level1ToCnsPlane1[25] = { /* range */
+static const codes_t big5Level1ToCnsPlane1[25] = { /* range */
{0xA140, 0x2121},
{0xA1F6, 0x2258},
{0xA1F7, 0x2257},
@@ -51,7 +51,7 @@ static codes_t big5Level1ToCnsPlane1[25] = { /* range */
};
/* map CNS 11643-1992 Plane 1 to Big5 Level 1 */
-static codes_t cnsPlane1ToBig5Level1[26] = { /* range */
+static const codes_t cnsPlane1ToBig5Level1[26] = { /* range */
{0x2121, 0xA140},
{0x2257, 0xA1F7},
{0x2258, 0xA1F6},
@@ -81,7 +81,7 @@ static codes_t cnsPlane1ToBig5Level1[26] = { /* range */
};
/* map Big5 Level 2 to CNS 11643-1992 Plane 2 */
-static codes_t big5Level2ToCnsPlane2[48] = { /* range */
+static const codes_t big5Level2ToCnsPlane2[48] = { /* range */
{0xC940, 0x2121},
{0xc94a, 0x0000},
{0xC94B, 0x212B},
@@ -133,7 +133,7 @@ static codes_t big5Level2ToCnsPlane2[48] = { /* range */
};
/* map CNS 11643-1992 Plane 2 to Big5 Level 2 */
-static codes_t cnsPlane2ToBig5Level2[49] = { /* range */
+static const codes_t cnsPlane2ToBig5Level2[49] = { /* range */
{0x2121, 0xC940},
{0x212B, 0xC94B},
{0x214C, 0xC9BE},
@@ -186,7 +186,7 @@ static codes_t cnsPlane2ToBig5Level2[49] = { /* range */
};
/* Big Five Level 1 Correspondence to CNS 11643-1992 Plane 4 */
-static unsigned short b1c4[][2] = {
+static const unsigned short b1c4[][2] = {
{0xC879, 0x2123},
{0xC87B, 0x2124},
{0xC87D, 0x212A},
@@ -194,7 +194,7 @@ static unsigned short b1c4[][2] = {
};
/* Big Five Level 2 Correspondence to CNS 11643-1992 Plane 3 */
-static unsigned short b2c3[][2] = {
+static const unsigned short b2c3[][2] = {
{0xF9D6, 0x4337},
{0xF9D7, 0x4F50},
{0xF9D8, 0x444E},
@@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = {
};
static unsigned short BinarySearchRange
- (codes_t *array, int high, unsigned short code)
+ (const codes_t *array, int high, unsigned short code)
{
int low,
mid,
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c b/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c
index 35e71a2ce5..a422a26d00 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c
@@ -44,8 +44,11 @@ big5_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_BIG5, PG_UTF8);
- LocalToUtf(src, dest, LUmapBIG5, NULL,
- sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), 0, PG_BIG5, len);
+ LocalToUtf(src, len, dest,
+ LUmapBIG5, lengthof(LUmapBIG5),
+ NULL, 0,
+ NULL,
+ PG_BIG5);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_big5(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_BIG5);
- UtfToLocal(src, dest, ULmapBIG5, NULL,
- sizeof(ULmapBIG5) / sizeof(pg_utf_to_local), 0, PG_BIG5, len);
+ UtfToLocal(src, len, dest,
+ ULmapBIG5, lengthof(ULmapBIG5),
+ NULL, 0,
+ NULL,
+ PG_BIG5);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
index 5d9e9150e4..f2b01e50a3 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
@@ -53,8 +53,11 @@ utf8_to_koi8r(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_KOI8R);
- UtfToLocal(src, dest, ULmapKOI8R, NULL,
- sizeof(ULmapKOI8R) / sizeof(pg_utf_to_local), 0, PG_KOI8R, len);
+ UtfToLocal(src, len, dest,
+ ULmapKOI8R, lengthof(ULmapKOI8R),
+ NULL, 0,
+ NULL,
+ PG_KOI8R);
PG_RETURN_VOID();
}
@@ -68,8 +71,11 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8R, PG_UTF8);
- LocalToUtf(src, dest, LUmapKOI8R, NULL,
- sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), 0, PG_KOI8R, len);
+ LocalToUtf(src, len, dest,
+ LUmapKOI8R, lengthof(LUmapKOI8R),
+ NULL, 0,
+ NULL,
+ PG_KOI8R);
PG_RETURN_VOID();
}
@@ -83,8 +89,11 @@ utf8_to_koi8u(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_KOI8U);
- UtfToLocal(src, dest, ULmapKOI8U, NULL,
- sizeof(ULmapKOI8U) / sizeof(pg_utf_to_local), 0, PG_KOI8U, len);
+ UtfToLocal(src, len, dest,
+ ULmapKOI8U, lengthof(ULmapKOI8U),
+ NULL, 0,
+ NULL,
+ PG_KOI8U);
PG_RETURN_VOID();
}
@@ -98,8 +107,11 @@ koi8u_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8U, PG_UTF8);
- LocalToUtf(src, dest, LUmapKOI8U, NULL,
- sizeof(LUmapKOI8U) / sizeof(pg_local_to_utf), 0, PG_KOI8U, len);
+ LocalToUtf(src, len, dest,
+ LUmapKOI8U, lengthof(LUmapKOI8U),
+ NULL, 0,
+ NULL,
+ PG_KOI8U);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c
index 15d079cfa6..a49eda8838 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c
@@ -46,10 +46,11 @@ euc_jis_2004_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_JIS_2004, PG_UTF8);
- LocalToUtf(src, dest, LUmapEUC_JIS_2004, LUmapEUC_JIS_2004_combined,
- sizeof(LUmapEUC_JIS_2004) / sizeof(pg_local_to_utf),
- sizeof(LUmapEUC_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
- PG_EUC_JIS_2004, len);
+ LocalToUtf(src, len, dest,
+ LUmapEUC_JIS_2004, lengthof(LUmapEUC_JIS_2004),
+ LUmapEUC_JIS_2004_combined, lengthof(LUmapEUC_JIS_2004_combined),
+ NULL,
+ PG_EUC_JIS_2004);
PG_RETURN_VOID();
}
@@ -63,10 +64,11 @@ utf8_to_euc_jis_2004(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JIS_2004);
- UtfToLocal(src, dest, ULmapEUC_JIS_2004, ULmapEUC_JIS_2004_combined,
- sizeof(ULmapEUC_JIS_2004) / sizeof(pg_utf_to_local),
- sizeof(ULmapEUC_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
- PG_EUC_JIS_2004, len);
+ UtfToLocal(src, len, dest,
+ ULmapEUC_JIS_2004, lengthof(ULmapEUC_JIS_2004),
+ ULmapEUC_JIS_2004_combined, lengthof(ULmapEUC_JIS_2004_combined),
+ NULL,
+ PG_EUC_JIS_2004);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c
index 7a321aa38e..8332926317 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c
@@ -44,8 +44,11 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_CN, PG_UTF8);
- LocalToUtf(src, dest, LUmapEUC_CN, NULL,
- sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), 0, PG_EUC_CN, len);
+ LocalToUtf(src, len, dest,
+ LUmapEUC_CN, lengthof(LUmapEUC_CN),
+ NULL, 0,
+ NULL,
+ PG_EUC_CN);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_CN);
- UtfToLocal(src, dest, ULmapEUC_CN, NULL,
- sizeof(ULmapEUC_CN) / sizeof(pg_utf_to_local), 0, PG_EUC_CN, len);
+ UtfToLocal(src, len, dest,
+ ULmapEUC_CN, lengthof(ULmapEUC_CN),
+ NULL, 0,
+ NULL,
+ PG_EUC_CN);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
index bc6d648435..6d9aeb4138 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
@@ -44,8 +44,11 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_JP, PG_UTF8);
- LocalToUtf(src, dest, LUmapEUC_JP, NULL,
- sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), 0, PG_EUC_JP, len);
+ LocalToUtf(src, len, dest,
+ LUmapEUC_JP, lengthof(LUmapEUC_JP),
+ NULL, 0,
+ NULL,
+ PG_EUC_JP);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JP);
- UtfToLocal(src, dest, ULmapEUC_JP, NULL,
- sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len);
+ UtfToLocal(src, len, dest,
+ ULmapEUC_JP, lengthof(ULmapEUC_JP),
+ NULL, 0,
+ NULL,
+ PG_EUC_JP);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
index 7233f06a7d..7edd09b115 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
@@ -44,8 +44,11 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_KR, PG_UTF8);
- LocalToUtf(src, dest, LUmapEUC_KR, NULL,
- sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), 0, PG_EUC_KR, len);
+ LocalToUtf(src, len, dest,
+ LUmapEUC_KR, lengthof(LUmapEUC_KR),
+ NULL, 0,
+ NULL,
+ PG_EUC_KR);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_KR);
- UtfToLocal(src, dest, ULmapEUC_KR, NULL,
- sizeof(ULmapEUC_KR) / sizeof(pg_utf_to_local), 0, PG_EUC_KR, len);
+ UtfToLocal(src, len, dest,
+ ULmapEUC_KR, lengthof(ULmapEUC_KR),
+ NULL, 0,
+ NULL,
+ PG_EUC_KR);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c
index 8bd093a59a..bc129993ba 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c
@@ -44,8 +44,11 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_TW, PG_UTF8);
- LocalToUtf(src, dest, LUmapEUC_TW, NULL,
- sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), 0, PG_EUC_TW, len);
+ LocalToUtf(src, len, dest,
+ LUmapEUC_TW, lengthof(LUmapEUC_TW),
+ NULL, 0,
+ NULL,
+ PG_EUC_TW);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_TW);
- UtfToLocal(src, dest, ULmapEUC_TW, NULL,
- sizeof(ULmapEUC_TW) / sizeof(pg_utf_to_local), 0, PG_EUC_TW, len);
+ UtfToLocal(src, len, dest,
+ ULmapEUC_TW, lengthof(ULmapEUC_TW),
+ NULL, 0,
+ NULL,
+ PG_EUC_TW);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
index 4427fea414..b41e4a84b0 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
@@ -44,8 +44,11 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_GB18030, PG_UTF8);
- LocalToUtf(src, dest, LUmapGB18030, NULL,
- sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), 0, PG_GB18030, len);
+ LocalToUtf(src, len, dest,
+ LUmapGB18030, lengthof(LUmapGB18030),
+ NULL, 0,
+ NULL,
+ PG_GB18030);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_GB18030);
- UtfToLocal(src, dest, ULmapGB18030, NULL,
- sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), 0, PG_GB18030, len);
+ UtfToLocal(src, len, dest,
+ ULmapGB18030, lengthof(ULmapGB18030),
+ NULL, 0,
+ NULL,
+ PG_GB18030);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c b/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c
index 456cc04bb6..adc33a68e6 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c
@@ -44,8 +44,11 @@ gbk_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_GBK, PG_UTF8);
- LocalToUtf(src, dest, LUmapGBK, NULL,
- sizeof(LUmapGBK) / sizeof(pg_local_to_utf), 0, PG_GBK, len);
+ LocalToUtf(src, len, dest,
+ LUmapGBK, lengthof(LUmapGBK),
+ NULL, 0,
+ NULL,
+ PG_GBK);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_gbk(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_GBK);
- UtfToLocal(src, dest, ULmapGBK, NULL,
- sizeof(ULmapGBK) / sizeof(pg_utf_to_local), 0, PG_GBK, len);
+ UtfToLocal(src, len, dest,
+ ULmapGBK, lengthof(ULmapGBK),
+ NULL, 0,
+ NULL,
+ PG_GBK);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
index 886e296d9a..39e4ce12e5 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
@@ -63,52 +63,52 @@ extern Datum utf8_to_iso8859(PG_FUNCTION_ARGS);
typedef struct
{
pg_enc encoding;
- pg_local_to_utf *map1; /* to UTF8 map name */
- pg_utf_to_local *map2; /* from UTF8 map name */
+ const pg_local_to_utf *map1; /* to UTF8 map name */
+ const pg_utf_to_local *map2; /* from UTF8 map name */
int size1; /* size of map1 */
int size2; /* size of map2 */
} pg_conv_map;
-static pg_conv_map maps[] = {
+static const pg_conv_map maps[] = {
{PG_LATIN2, LUmapISO8859_2, ULmapISO8859_2,
- sizeof(LUmapISO8859_2) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_2) / sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */
+ lengthof(LUmapISO8859_2),
+ lengthof(ULmapISO8859_2)}, /* ISO-8859-2 Latin 2 */
{PG_LATIN3, LUmapISO8859_3, ULmapISO8859_3,
- sizeof(LUmapISO8859_3) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_3) / sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */
+ lengthof(LUmapISO8859_3),
+ lengthof(ULmapISO8859_3)}, /* ISO-8859-3 Latin 3 */
{PG_LATIN4, LUmapISO8859_4, ULmapISO8859_4,
- sizeof(LUmapISO8859_4) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_4) / sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */
+ lengthof(LUmapISO8859_4),
+ lengthof(ULmapISO8859_4)}, /* ISO-8859-4 Latin 4 */
{PG_LATIN5, LUmapISO8859_9, ULmapISO8859_9,
- sizeof(LUmapISO8859_9) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_9) / sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */
+ lengthof(LUmapISO8859_9),
+ lengthof(ULmapISO8859_9)}, /* ISO-8859-9 Latin 5 */
{PG_LATIN6, LUmapISO8859_10, ULmapISO8859_10,
- sizeof(LUmapISO8859_10) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_10) / sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */
+ lengthof(LUmapISO8859_10),
+ lengthof(ULmapISO8859_10)}, /* ISO-8859-10 Latin 6 */
{PG_LATIN7, LUmapISO8859_13, ULmapISO8859_13,
- sizeof(LUmapISO8859_13) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_13) / sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */
+ lengthof(LUmapISO8859_13),
+ lengthof(ULmapISO8859_13)}, /* ISO-8859-13 Latin 7 */
{PG_LATIN8, LUmapISO8859_14, ULmapISO8859_14,
- sizeof(LUmapISO8859_14) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_14) / sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */
+ lengthof(LUmapISO8859_14),
+ lengthof(ULmapISO8859_14)}, /* ISO-8859-14 Latin 8 */
{PG_LATIN9, LUmapISO8859_15, ULmapISO8859_15,
- sizeof(LUmapISO8859_15) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_15) / sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */
+ lengthof(LUmapISO8859_15),
+ lengthof(ULmapISO8859_15)}, /* ISO-8859-15 Latin 9 */
{PG_LATIN10, LUmapISO8859_16, ULmapISO8859_16,
- sizeof(LUmapISO8859_16) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_16) / sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */
+ lengthof(LUmapISO8859_16),
+ lengthof(ULmapISO8859_16)}, /* ISO-8859-16 Latin 10 */
{PG_ISO_8859_5, LUmapISO8859_5, ULmapISO8859_5,
- sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local)}, /* ISO-8859-5 */
+ lengthof(LUmapISO8859_5),
+ lengthof(ULmapISO8859_5)}, /* ISO-8859-5 */
{PG_ISO_8859_6, LUmapISO8859_6, ULmapISO8859_6,
- sizeof(LUmapISO8859_6) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_6) / sizeof(pg_utf_to_local)}, /* ISO-8859-6 */
+ lengthof(LUmapISO8859_6),
+ lengthof(ULmapISO8859_6)}, /* ISO-8859-6 */
{PG_ISO_8859_7, LUmapISO8859_7, ULmapISO8859_7,
- sizeof(LUmapISO8859_7) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_7) / sizeof(pg_utf_to_local)}, /* ISO-8859-7 */
+ lengthof(LUmapISO8859_7),
+ lengthof(ULmapISO8859_7)}, /* ISO-8859-7 */
{PG_ISO_8859_8, LUmapISO8859_8, ULmapISO8859_8,
- sizeof(LUmapISO8859_8) / sizeof(pg_local_to_utf),
- sizeof(ULmapISO8859_8) / sizeof(pg_utf_to_local)}, /* ISO-8859-8 */
+ lengthof(LUmapISO8859_8),
+ lengthof(ULmapISO8859_8)}, /* ISO-8859-8 */
};
Datum
@@ -122,18 +122,23 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(-1, PG_UTF8);
- for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
+ for (i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
- LocalToUtf(src, dest, maps[i].map1, NULL, maps[i].size1, 0, encoding, len);
+ LocalToUtf(src, len, dest,
+ maps[i].map1, maps[i].size1,
+ NULL, 0,
+ NULL,
+ encoding);
PG_RETURN_VOID();
}
}
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));
+ errmsg("unexpected encoding ID %d for ISO 8859 character sets",
+ encoding)));
PG_RETURN_VOID();
}
@@ -149,18 +154,23 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1);
- for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
+ for (i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
- UtfToLocal(src, dest, maps[i].map2, NULL, maps[i].size2, 0, encoding, len);
+ UtfToLocal(src, len, dest,
+ maps[i].map2, maps[i].size2,
+ NULL, 0,
+ NULL,
+ encoding);
PG_RETURN_VOID();
}
}
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));
+ errmsg("unexpected encoding ID %d for ISO 8859 character sets",
+ encoding)));
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c
index 42c0105854..15b49f24b1 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c
@@ -44,8 +44,11 @@ johab_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_JOHAB, PG_UTF8);
- LocalToUtf(src, dest, LUmapJOHAB, NULL,
- sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), 0, PG_JOHAB, len);
+ LocalToUtf(src, len, dest,
+ LUmapJOHAB, lengthof(LUmapJOHAB),
+ NULL, 0,
+ NULL,
+ PG_JOHAB);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_johab(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_JOHAB);
- UtfToLocal(src, dest, ULmapJOHAB, NULL,
- sizeof(ULmapJOHAB) / sizeof(pg_utf_to_local), 0, PG_JOHAB, len);
+ UtfToLocal(src, len, dest,
+ ULmapJOHAB, lengthof(ULmapJOHAB),
+ NULL, 0,
+ NULL,
+ PG_JOHAB);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c b/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c
index 7f7e7b0b0b..7a3281b640 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c
@@ -44,8 +44,11 @@ sjis_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_SJIS, PG_UTF8);
- LocalToUtf(src, dest, LUmapSJIS, NULL,
- sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), 0, PG_SJIS, len);
+ LocalToUtf(src, len, dest,
+ LUmapSJIS, lengthof(LUmapSJIS),
+ NULL, 0,
+ NULL,
+ PG_SJIS);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_sjis(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_SJIS);
- UtfToLocal(src, dest, ULmapSJIS, NULL,
- sizeof(ULmapSJIS) / sizeof(pg_utf_to_local), 0, PG_SJIS, len);
+ UtfToLocal(src, len, dest,
+ ULmapSJIS, lengthof(ULmapSJIS),
+ NULL, 0,
+ NULL,
+ PG_SJIS);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c b/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c
index 2acdcacaaa..29f4256fe0 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c
@@ -46,10 +46,11 @@ shift_jis_2004_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_SHIFT_JIS_2004, PG_UTF8);
- LocalToUtf(src, dest, LUmapSHIFT_JIS_2004, LUmapSHIFT_JIS_2004_combined,
- sizeof(LUmapSHIFT_JIS_2004) / sizeof(pg_local_to_utf),
- sizeof(LUmapSHIFT_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
- PG_SHIFT_JIS_2004, len);
+ LocalToUtf(src, len, dest,
+ LUmapSHIFT_JIS_2004, lengthof(LUmapSHIFT_JIS_2004),
+ LUmapSHIFT_JIS_2004_combined, lengthof(LUmapSHIFT_JIS_2004_combined),
+ NULL,
+ PG_SHIFT_JIS_2004);
PG_RETURN_VOID();
}
@@ -63,10 +64,11 @@ utf8_to_shift_jis_2004(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_SHIFT_JIS_2004);
- UtfToLocal(src, dest, ULmapSHIFT_JIS_2004, ULmapSHIFT_JIS_2004_combined,
- sizeof(ULmapSHIFT_JIS_2004) / sizeof(pg_utf_to_local),
- sizeof(ULmapSHIFT_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
- PG_SHIFT_JIS_2004, len);
+ UtfToLocal(src, len, dest,
+ ULmapSHIFT_JIS_2004, lengthof(ULmapSHIFT_JIS_2004),
+ ULmapSHIFT_JIS_2004_combined, lengthof(ULmapSHIFT_JIS_2004_combined),
+ NULL,
+ PG_SHIFT_JIS_2004);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c b/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c
index 72b72d87bb..984980935d 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c
@@ -44,8 +44,11 @@ uhc_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UHC, PG_UTF8);
- LocalToUtf(src, dest, LUmapUHC, NULL,
- sizeof(LUmapUHC) / sizeof(pg_local_to_utf), 0, PG_UHC, len);
+ LocalToUtf(src, len, dest,
+ LUmapUHC, lengthof(LUmapUHC),
+ NULL, 0,
+ NULL,
+ PG_UHC);
PG_RETURN_VOID();
}
@@ -59,8 +62,11 @@ utf8_to_uhc(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_UHC);
- UtfToLocal(src, dest, ULmapUHC, NULL,
- sizeof(ULmapUHC) / sizeof(pg_utf_to_local), 0, PG_UHC, len);
+ UtfToLocal(src, len, dest,
+ ULmapUHC, lengthof(ULmapUHC),
+ NULL, 0,
+ NULL,
+ PG_UHC);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c b/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
index 97d890206f..c2a4ec35f7 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
@@ -59,46 +59,46 @@ extern Datum utf8_to_win(PG_FUNCTION_ARGS);
typedef struct
{
pg_enc encoding;
- pg_local_to_utf *map1; /* to UTF8 map name */
- pg_utf_to_local *map2; /* from UTF8 map name */
+ const pg_local_to_utf *map1; /* to UTF8 map name */
+ const pg_utf_to_local *map2; /* from UTF8 map name */
int size1; /* size of map1 */
int size2; /* size of map2 */
} pg_conv_map;
-static pg_conv_map maps[] = {
+static const pg_conv_map maps[] = {
{PG_WIN866, LUmapWIN866, ULmapWIN866,
- sizeof(LUmapWIN866) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN866) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN866),
+ lengthof(ULmapWIN866)},
{PG_WIN874, LUmapWIN874, ULmapWIN874,
- sizeof(LUmapWIN874) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN874) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN874),
+ lengthof(ULmapWIN874)},
{PG_WIN1250, LUmapWIN1250, ULmapWIN1250,
- sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1250),
+ lengthof(ULmapWIN1250)},
{PG_WIN1251, LUmapWIN1251, ULmapWIN1251,
- sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1251) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1251),
+ lengthof(ULmapWIN1251)},
{PG_WIN1252, LUmapWIN1252, ULmapWIN1252,
- sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1252) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1252),
+ lengthof(ULmapWIN1252)},
{PG_WIN1253, LUmapWIN1253, ULmapWIN1253,
- sizeof(LUmapWIN1253) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1253) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1253),
+ lengthof(ULmapWIN1253)},
{PG_WIN1254, LUmapWIN1254, ULmapWIN1254,
- sizeof(LUmapWIN1254) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1254) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1254),
+ lengthof(ULmapWIN1254)},
{PG_WIN1255, LUmapWIN1255, ULmapWIN1255,
- sizeof(LUmapWIN1255) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1255) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1255),
+ lengthof(ULmapWIN1255)},
{PG_WIN1256, LUmapWIN1256, ULmapWIN1256,
- sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1256),
+ lengthof(ULmapWIN1256)},
{PG_WIN1257, LUmapWIN1257, ULmapWIN1257,
- sizeof(LUmapWIN1257) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1257) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1257),
+ lengthof(ULmapWIN1257)},
{PG_WIN1258, LUmapWIN1258, ULmapWIN1258,
- sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf),
- sizeof(ULmapWIN1258) / sizeof(pg_utf_to_local)},
+ lengthof(LUmapWIN1258),
+ lengthof(ULmapWIN1258)},
};
Datum
@@ -112,18 +112,23 @@ win_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(-1, PG_UTF8);
- for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
+ for (i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
- LocalToUtf(src, dest, maps[i].map1, NULL, maps[i].size1, 0, encoding, len);
+ LocalToUtf(src, len, dest,
+ maps[i].map1, maps[i].size1,
+ NULL, 0,
+ NULL,
+ encoding);
PG_RETURN_VOID();
}
}
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("unexpected encoding ID %d for WIN character sets", encoding)));
+ errmsg("unexpected encoding ID %d for WIN character sets",
+ encoding)));
PG_RETURN_VOID();
}
@@ -139,18 +144,23 @@ utf8_to_win(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1);
- for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
+ for (i = 0; i < lengthof(maps); i++)
{
if (encoding == maps[i].encoding)
{
- UtfToLocal(src, dest, maps[i].map2, NULL, maps[i].size2, 0, encoding, len);
+ UtfToLocal(src, len, dest,
+ maps[i].map2, maps[i].size2,
+ NULL, 0,
+ NULL,
+ encoding);
PG_RETURN_VOID();
}
}
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("unexpected encoding ID %d for WIN character sets", encoding)));
+ errmsg("unexpected encoding ID %d for WIN character sets",
+ encoding)));
PG_RETURN_VOID();
}
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index f7222fc177..f8b0edc678 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -366,9 +366,16 @@ typedef struct
extern const pg_wchar_tbl pg_wchar_table[];
/*
+ * Data structures for conversions between UTF-8 and other encodings
+ * (UtfToLocal() and LocalToUtf()). In these data structures, characters of
+ * either encoding are represented by uint32 words; hence we can only support
+ * characters up to 4 bytes long. For example, the byte sequence 0xC2 0x89
+ * would be represented by 0x0000C289, and 0xE8 0xA2 0xB4 by 0x00E8A2B4.
+ *
+ * Maps are arrays of these structs, which must be in order by the lookup key
+ * (so that bsearch() can be used).
+ *
* UTF-8 to local code conversion map
- * Note that we limit the max length of UTF-8 to 4 bytes,
- * which is UCS-4 00010000-001FFFFF range.
*/
typedef struct
{
@@ -386,7 +393,7 @@ typedef struct
} pg_local_to_utf;
/*
- * UTF-8 to local code conversion map(combined characters)
+ * UTF-8 to local code conversion map (for combined characters)
*/
typedef struct
{
@@ -396,7 +403,7 @@ typedef struct
} pg_utf_to_local_combined;
/*
- * local code to UTF-8 conversion map(combined characters)
+ * local code to UTF-8 conversion map (for combined characters)
*/
typedef struct
{
@@ -406,6 +413,13 @@ typedef struct
} pg_local_to_utf_combined;
/*
+ * callback function for algorithmic encoding conversions (in either direction)
+ *
+ * if function returns zero, it does not know how to convert the code
+ */
+typedef uint32 (*utf_local_conversion_func) (uint32 code);
+
+/*
* Support macro for encoding conversion functions to validate their
* arguments. (This could be made more compact if we included fmgr.h
* here, but we don't want to do that because this header file is also
@@ -494,13 +508,18 @@ extern char *pg_server_to_any(const char *s, int len, int encoding);
extern unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc);
extern unsigned short CNStoBIG5(unsigned short cns, unsigned char lc);
-extern void LocalToUtf(const unsigned char *iso, unsigned char *utf,
- const pg_local_to_utf *map, const pg_local_to_utf_combined *cmap,
- int size1, int size2, int encoding, int len);
-
-extern void UtfToLocal(const unsigned char *utf, unsigned char *iso,
- const pg_utf_to_local *map, const pg_utf_to_local_combined *cmap,
- int size1, int size2, int encoding, int len);
+extern void UtfToLocal(const unsigned char *utf, int len,
+ unsigned char *iso,
+ const pg_utf_to_local *map, int mapsize,
+ const pg_utf_to_local_combined *cmap, int cmapsize,
+ utf_local_conversion_func conv_func,
+ int encoding);
+extern void LocalToUtf(const unsigned char *iso, int len,
+ unsigned char *utf,
+ const pg_local_to_utf *map, int mapsize,
+ const pg_local_to_utf_combined *cmap, int cmapsize,
+ utf_local_conversion_func conv_func,
+ int encoding);
extern bool pg_verifymbstr(const char *mbstr, int len, bool noError);
extern bool pg_verify_mbstr(int encoding, const char *mbstr, int len,