1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Don't print uninitialized hash values in debug mode.

This commit is contained in:
Bruno Haible
2018-09-08 16:37:56 +02:00
parent 24f492fd8d
commit 5f4cf73df2
2 changed files with 19 additions and 5 deletions

View File

@@ -1,3 +1,11 @@
2018-09-08 Bruno Haible <bruno@clisp.org>
Don't print uninitialized hash values in debug mode.
Reported by Frank Wojcik <frankw@touristinresidence.com> in
<https://savannah.gnu.org/patch/?9560>.
* src/output.cc (output_keyword_entry): Add an 'is_duplicate' argument.
(Output::output_keyword_table): Update callers.
2018-09-08 Bruno Haible <bruno@clisp.org> 2018-09-08 Bruno Haible <bruno@clisp.org>
Improve the speed of the positions search. Improve the speed of the positions search.

View File

@@ -1172,7 +1172,7 @@ Output::output_string_pool () const
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
static void static void
output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent) output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent, bool is_duplicate)
{ {
if (option[TYPE]) if (option[TYPE])
output_line_directive (temp->_lineno); output_line_directive (temp->_lineno);
@@ -1205,8 +1205,14 @@ output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent
printf ("}"); printf ("}");
} }
if (option[DEBUG]) if (option[DEBUG])
printf (" /* hash value = %d, index = %d */", {
temp->_hash_value, temp->_final_index); printf (" /* ");
if (is_duplicate)
printf ("hash value duplicate, ");
else
printf ("hash value = %d, ", temp->_hash_value);
printf ("index = %d */", temp->_final_index);
}
} }
static void static void
@@ -1297,7 +1303,7 @@ Output::output_keyword_table () const
keyword->_final_index = index; keyword->_final_index = index;
output_keyword_entry (keyword, index, indent); output_keyword_entry (keyword, index, indent, false);
/* Deal with duplicates specially. */ /* Deal with duplicates specially. */
if (keyword->_duplicate_link) // implies option[DUP] if (keyword->_duplicate_link) // implies option[DUP]
@@ -1311,7 +1317,7 @@ Output::output_keyword_table () const
keyword->_allchars_length) == 0 keyword->_allchars_length) == 0
? keyword->_final_index ? keyword->_final_index
: links->_final_index); : links->_final_index);
output_keyword_entry (links, stringpool_index, indent); output_keyword_entry (links, stringpool_index, indent, true);
} }
index++; index++;