mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
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.
This commit is contained in:
@@ -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>
|
2018-07-25 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
Avoid "implicit fallthrough" warnings in the generated code.
|
Avoid "implicit fallthrough" warnings in the generated code.
|
||||||
|
|||||||
@@ -851,6 +851,8 @@ Output::output_hash_function () const
|
|||||||
/* First the asso_values array. */
|
/* First the asso_values array. */
|
||||||
if (_key_positions.get_size() > 0)
|
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"
|
printf (" static %s%s asso_values[] =\n"
|
||||||
" {",
|
" {",
|
||||||
const_readonly_array,
|
const_readonly_array,
|
||||||
@@ -858,9 +860,9 @@ Output::output_hash_function () const
|
|||||||
|
|
||||||
const int columns = 10;
|
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;
|
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++;
|
field_width++;
|
||||||
|
|
||||||
for (unsigned int count = 0; count < _alpha_size; count++)
|
for (unsigned int count = 0; count < _alpha_size; count++)
|
||||||
|
|||||||
Reference in New Issue
Block a user