On Mon, Oct 19, 2020 at 12:12:00PM -0400, John Naylor wrote: > I see, I should have looked for that when Michael mentioned it. We could > left-justify instead, as in the attached. If it were up to me, though, I'd > just format it like pgindent expects, even if not nice looking. It's just a > bunch of numbers.
The aligned numbers have the advantage to make the checks of the code generated easier, for the contents and the format produced. So using a right padding as you are suggesting here rather than a new exception in .gitattributes sounds fine to me. I simplified things a bit as the attached, getting rid of the last comma while on it. Does that look fine to you? -- Michael
diff --git a/src/tools/PerfectHash.pm b/src/tools/PerfectHash.pm
index d6841589a3..964f79b71a 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";
signature.asc
Description: PGP signature
