v1-0004-Simplify-code-generation-code.patch
text/plain
Filename: v1-0004-Simplify-code-generation-code.patch
Type: text/plain
Part: 3
Patch
Format: format-patch
Series: patch v1-0004
Subject: Simplify code generation code
| File | + | − |
|---|---|---|
| src/backend/utils/mb/Unicode/convutils.pm | 14 | 23 |
| src/backend/utils/mb/Unicode/euc_jis_2004_to_utf8.map | 1 | 1 |
| src/backend/utils/mb/Unicode/shift_jis_2004_to_utf8.map | 1 | 1 |
| src/backend/utils/mb/Unicode/utf8_to_euc_jis_2004.map | 1 | 1 |
| src/backend/utils/mb/Unicode/utf8_to_shift_jis_2004.map | 1 | 1 |
From 9dd3a3be9cb08fd05db26acbbe4800f4bf82e5ab Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 22 Jun 2021 09:06:28 +0200
Subject: [PATCH v1 4/5] Simplify code generation code
convutils.pm spent a fair amount of effort to avoid printing out a
trailing comma in an array initializer, which isn't actually
necessary. We can simplify that code. This also makes the generated
code look better indented.
---
src/backend/utils/mb/Unicode/convutils.pm | 37 +++++++------------
.../utils/mb/Unicode/euc_jis_2004_to_utf8.map | 2 +-
.../mb/Unicode/shift_jis_2004_to_utf8.map | 2 +-
.../utils/mb/Unicode/utf8_to_euc_jis_2004.map | 2 +-
.../mb/Unicode/utf8_to_shift_jis_2004.map | 2 +-
5 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/src/backend/utils/mb/Unicode/convutils.pm b/src/backend/utils/mb/Unicode/convutils.pm
index 8369e91b2d..9a230e6dfe 100644
--- a/src/backend/utils/mb/Unicode/convutils.pm
+++ b/src/backend/utils/mb/Unicode/convutils.pm
@@ -169,34 +169,29 @@ sub print_from_utf8_combined_map
{
my ($out, $charset, $table, $verbose) = @_;
- my $last_comment = "";
-
printf $out "\n/* Combined character map */\n";
printf $out
"static const pg_utf_to_local_combined ULmap${charset}_combined[%d] = {\n",
scalar(@$table);
- my $first = 1;
foreach my $i (sort { $a->{utf8} <=> $b->{utf8} } @$table)
{
- print($out ",") if (!$first);
- $first = 0;
- print $out "\t/* $last_comment */"
- if ($verbose && $last_comment ne "");
+ my $comment;
- printf $out "\n {0x%08x, 0x%08x, 0x%04x}",
+ printf $out " {0x%08x, 0x%08x, 0x%04x},",
$i->{utf8}, $i->{utf8_second}, $i->{code};
if ($verbose >= 2)
{
- $last_comment =
+ $comment =
sprintf("%s:%d %s", $i->{f}, $i->{l}, $i->{comment});
}
elsif ($verbose >= 1)
{
- $last_comment = $i->{comment};
+ $comment = $i->{comment};
}
+ print $out "\t/* $comment */" if $comment;
+ print $out "\n";
}
- print $out "\t/* $last_comment */" if ($verbose && $last_comment ne "");
- print $out "\n};\n";
+ print $out "};\n";
return;
}
@@ -204,8 +199,6 @@ sub print_to_utf8_combined_map
{
my ($out, $charset, $table, $verbose) = @_;
- my $last_comment = "";
-
printf $out "\n/* Combined character map */\n";
printf $out
"static const pg_local_to_utf_combined LUmap${charset}_combined[%d] = {\n",
@@ -214,26 +207,24 @@ sub print_to_utf8_combined_map
my $first = 1;
foreach my $i (sort { $a->{code} <=> $b->{code} } @$table)
{
- print($out ",") if (!$first);
- $first = 0;
- print $out "\t/* $last_comment */"
- if ($verbose && $last_comment ne "");
+ my $comment;
- printf $out "\n {0x%04x, 0x%08x, 0x%08x}",
+ printf $out " {0x%04x, 0x%08x, 0x%08x},",
$i->{code}, $i->{utf8}, $i->{utf8_second};
if ($verbose >= 2)
{
- $last_comment =
+ $comment =
sprintf("%s:%d %s", $i->{f}, $i->{l}, $i->{comment});
}
elsif ($verbose >= 1)
{
- $last_comment = $i->{comment};
+ $comment = $i->{comment};
}
+ print $out "\t/* $comment */" if $comment;
+ print $out "\n";
}
- print $out "\t/* $last_comment */" if ($verbose && $last_comment ne "");
- print $out "\n};\n";
+ print $out "};\n";
return;
}
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 3a8fc9d26f..7096fbb263 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
@@ -3439,5 +3439,5 @@ static const pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[25] = {
{0xabce, 0x0000c99a, 0x0000cc80}, /* U+025A+0300 [2000] */
{0xabcf, 0x0000c99a, 0x0000cc81}, /* U+025A+0301 [2000] */
{0xabe5, 0x0000cba9, 0x0000cba5}, /* U+02E9+02E5 [2000] */
- {0xabe6, 0x0000cba5, 0x0000cba9} /* U+02E5+02E9 [2000] */
+ {0xabe6, 0x0000cba5, 0x0000cba9}, /* U+02E5+02E9 [2000] */
};
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 3c107cbb7b..cd0bd7a452 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
@@ -3230,5 +3230,5 @@ static const pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[25] = {
{0x866d, 0x0000c99a, 0x0000cc80}, /* U+025A+0300 [2000] */
{0x866e, 0x0000c99a, 0x0000cc81}, /* U+025A+0301 [2000] */
{0x8685, 0x0000cba9, 0x0000cba5}, /* U+02E9+02E5 [2000] */
- {0x8686, 0x0000cba5, 0x0000cba9} /* U+02E5+02E9 [2000] */
+ {0x8686, 0x0000cba5, 0x0000cba9}, /* U+02E5+02E9 [2000] */
};
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 0d47463805..3de9d6360d 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
@@ -12563,5 +12563,5 @@ static const pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[25] = {
{0x00e382bb, 0x00e3829a, 0xa5fc}, /* U+30BB+309A [2000] */
{0x00e38384, 0x00e3829a, 0xa5fd}, /* U+30C4+309A [2000] */
{0x00e38388, 0x00e3829a, 0xa5fe}, /* U+30C8+309A [2000] */
- {0x00e387b7, 0x00e3829a, 0xa6f8} /* U+31F7+309A [2000] */
+ {0x00e387b7, 0x00e3829a, 0xa6f8}, /* U+31F7+309A [2000] */
};
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 202ebb25c1..924ccc114e 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
@@ -7681,5 +7681,5 @@ static const pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[25] = {
{0x00e382bb, 0x00e3829a, 0x839c}, /* U+30BB+309A [2000] */
{0x00e38384, 0x00e3829a, 0x839d}, /* U+30C4+309A [2000] */
{0x00e38388, 0x00e3829a, 0x839e}, /* U+30C8+309A [2000] */
- {0x00e387b7, 0x00e3829a, 0x83f6} /* U+31F7+309A [2000] */
+ {0x00e387b7, 0x00e3829a, 0x83f6}, /* U+31F7+309A [2000] */
};
--
2.32.0