summaryrefslogtreecommitdiff
path: root/src/tools/PerfectHash.pm
diff options
context:
space:
mode:
authorMichael Paquier2020-10-21 00:22:27 +0000
committerMichael Paquier2020-10-21 00:22:27 +0000
commit19ae53c92d5f5bdfb971d560a562e84c5f65c8b0 (patch)
treec6ec0417d11267670b4eb17a73721f5dd40a913a /src/tools/PerfectHash.pm
parentbbb927b4db9b3b449ccd0f76c1296de382a2f0c1 (diff)
Review format of code generated by PerfectHash.pm
80f8eb7 has added to the normalization quick check headers some code generated by PerfectHash.pm that is incompatible with the settings of gitattributes for this repository, as whitespaces followed a set of tabs for the first element of a line in the table. Instead of adding a new exception to gitattributes, rework the format generated so as a right padding with spaces is used instead of a left padding. This keeps the table generated in a readable shape with its set of columns, making unnecessary an update of gitattributes. Reported-by: Peter Eisentraut Author: John Naylor Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/tools/PerfectHash.pm')
-rw-r--r--src/tools/PerfectHash.pm13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/tools/PerfectHash.pm b/src/tools/PerfectHash.pm
index d6841589a39..964f79b71a2 100644
--- a/src/tools/PerfectHash.pm
+++ b/src/tools/PerfectHash.pm
@@ -121,13 +121,16 @@ sub generate_hash_function
{
$f .= sprintf "%s(const void *key, size_t keylen)\n{\n", $funcname;
}
- $f .= sprintf "\tstatic const %s h[%d] = {\n", $elemtype, $nhash;
+ $f .= sprintf "\tstatic const %s h[%d] = {\n\t\t", $elemtype, $nhash;
for (my $i = 0; $i < $nhash; $i++)
{
- $f .= sprintf "%s%6d,%s",
- ($i % 8 == 0 ? "\t\t" : " "),
- $hashtab[$i],
- ($i % 8 == 7 ? "\n" : "");
+ # Hash element.
+ $f .= sprintf "%d", $hashtab[$i];
+ next if ($i == $nhash - 1);
+
+ # Optional indentation and newline, with eight items per line.
+ $f .= sprintf ",%s",
+ ($i % 8 == 7 ? "\n\t\t" : ' ' x (6 - length($hashtab[$i])));
}
$f .= sprintf "\n" if ($nhash % 8 != 0);
$f .= sprintf "\t};\n\n";