summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2018-09-08 15:36:36 +0200
committerBruno Haible <bruno@clisp.org>2018-09-08 15:36:36 +0200
commita720310c28ef0f491a81f69dfa83a538fdbc1d79 (patch)
tree4e21b104268446f01648738aeb58945a210aa5b6
parent0d37a8763d9a5169ee2cb71a0281f859ca159b87 (diff)
downloadgperf-a720310c28ef0f491a81f69dfa83a538fdbc1d79.tar.gz
Correct width of columns when outputting the asso_values array.
Patch by Frank Wojcik <frankw@touristinresidence.com>. * src/output.cc (Output::output_hash_function): Increase the field_width by 1 if _max_hash_value+1 is a power of 10.
-rw-r--r--ChangeLog7
-rw-r--r--src/output.cc6
2 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f84fee..2cccbc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-08 Bruno Haible <bruno@clisp.org>
+
+ Correct width of columns when outputting the asso_values array.
+ Patch by Frank Wojcik <frankw@touristinresidence.com>.
+ * src/output.cc (Output::output_hash_function): Increase the
+ field_width by 1 if _max_hash_value+1 is a power of 10.
+
2018-07-25 Bruno Haible <bruno@clisp.org>
Avoid "implicit fallthrough" warnings in the generated code.
diff --git a/src/output.cc b/src/output.cc
index 2e95a31..e8370b1 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -851,6 +851,8 @@ Output::output_hash_function () const
/* First the asso_values array. */
if (_key_positions.get_size() > 0)
{
+ /* The values in the asso_values array are all unsigned integers
+ <= MAX_HASH_VALUE + 1. */
printf (" static %s%s asso_values[] =\n"
" {",
const_readonly_array,
@@ -858,9 +860,9 @@ Output::output_hash_function () const
const int columns = 10;
- /* Calculate maximum number of digits required for MAX_HASH_VALUE. */
+ /* Calculate maximum number of digits required for MAX_HASH_VALUE + 1. */
int field_width = 2;
- for (int trunc = _max_hash_value; (trunc /= 10) > 0;)
+ for (int trunc = _max_hash_value + 1; (trunc /= 10) > 0;)
field_width++;
for (unsigned int count = 0; count < _alpha_size; count++)