mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Add two more assertions.
Suggested by Frank Wojcik. * src/search.cc (Search::find_asso_values): Assert that a step's _changing_count is positive.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2025-04-20 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
Add two more assertions.
|
||||||
|
Suggested by Frank Wojcik.
|
||||||
|
* src/search.cc (Search::find_asso_values): Assert that a step's
|
||||||
|
_changing_count is positive.
|
||||||
|
|
||||||
2025-04-20 Bruno Haible <bruno@clisp.org>
|
2025-04-20 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
Fix typo in comment.
|
Fix typo in comment.
|
||||||
|
|||||||
@@ -967,7 +967,7 @@ struct Partition
|
|||||||
struct Step
|
struct Step
|
||||||
{
|
{
|
||||||
/* The characters whose values are being determined in this step. */
|
/* The characters whose values are being determined in this step. */
|
||||||
unsigned int _changing_count;
|
unsigned int _changing_count; /* > 0 */
|
||||||
unsigned int * _changing;
|
unsigned int * _changing;
|
||||||
/* Exclusive upper bound for the _asso_values[c] of this step.
|
/* Exclusive upper bound for the _asso_values[c] of this step.
|
||||||
A power of 2. */
|
A power of 2. */
|
||||||
@@ -1276,6 +1276,11 @@ Search::find_asso_values ()
|
|||||||
if (undetermined[c] && !step->_undetermined[c])
|
if (undetermined[c] && !step->_undetermined[c])
|
||||||
changing[changing_count++] = c;
|
changing[changing_count++] = c;
|
||||||
|
|
||||||
|
/* The set of changing characters is non-empty, since it contains
|
||||||
|
chosen_c. */
|
||||||
|
if (changing_count == 0)
|
||||||
|
abort ();
|
||||||
|
|
||||||
step->_changing = changing;
|
step->_changing = changing;
|
||||||
step->_changing_count = changing_count;
|
step->_changing_count = changing_count;
|
||||||
|
|
||||||
@@ -1344,6 +1349,8 @@ Search::find_asso_values ()
|
|||||||
|
|
||||||
/* Initialize the asso_values[]. */
|
/* Initialize the asso_values[]. */
|
||||||
unsigned int k = step->_changing_count;
|
unsigned int k = step->_changing_count;
|
||||||
|
if (k == 0)
|
||||||
|
abort ();
|
||||||
for (unsigned int i = 0; i < k; i++)
|
for (unsigned int i = 0; i < k; i++)
|
||||||
{
|
{
|
||||||
unsigned int c = step->_changing[i];
|
unsigned int c = step->_changing[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user