diff --git a/src/tools/PerfectHash.pm b/src/tools/PerfectHash.pm index d6841589a3..fbfac79163 100644 --- a/src/tools/PerfectHash.pm +++ b/src/tools/PerfectHash.pm @@ -121,13 +121,12 @@ 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" : " "), + $f .= sprintf "%d,%s", $hashtab[$i], - ($i % 8 == 7 ? "\n" : ""); + ($i == $nhash-1 ? "" : $i % 8 == 7 ? "\n\t\t" : ' ' x (6 - length($hashtab[$i]))); } $f .= sprintf "\n" if ($nhash % 8 != 0); $f .= sprintf "\t};\n\n";