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

Fix g++ -Wall warnings.

This commit is contained in:
Bruno Haible
2016-11-25 20:03:51 +01:00
parent a4e455187f
commit efd1fd8439
2 changed files with 56 additions and 39 deletions

View File

@@ -1,3 +1,11 @@
2016-11-25 Bruno Haible <bruno@clisp.org>
Fix g++ -Wall warnings.
* src/search.cc (Search::prepare, Search::find_positions,
Search::optimize): Add braces in 'if (...) for (...)', to pacify
g++ 4.6.3 warnings "suggest explicit braces to avoid ambiguous 'else'"
(although there is no 'else'!).
2016-11-25 Bruno Haible <bruno@clisp.org> 2016-11-25 Bruno Haible <bruno@clisp.org>
Fix typo in autogen.sh, introduced on 2012-07-01. Fix typo in autogen.sh, introduced on 2012-07-01.

View File

@@ -1,5 +1,5 @@
/* Search algorithm. /* Search algorithm.
Copyright (C) 1989-1998, 2000, 2002, 2009 Free Software Foundation, Inc. Copyright (C) 1989-1998, 2000, 2002, 2009, 2016 Free Software Foundation, Inc.
Written by Douglas C. Schmidt <schmidt@ics.uci.edu> Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
and Bruno Haible <bruno@clisp.org>. and Bruno Haible <bruno@clisp.org>.
@@ -160,6 +160,7 @@ Search::prepare ()
/* Exit program if the characters in the keywords are not in the required /* Exit program if the characters in the keywords are not in the required
range. */ range. */
if (option[SEVENBIT]) if (option[SEVENBIT])
{
for (KeywordExt_List *temp = _head; temp; temp = temp->rest()) for (KeywordExt_List *temp = _head; temp; temp = temp->rest())
{ {
KeywordExt *keyword = temp->first(); KeywordExt *keyword = temp->first();
@@ -175,6 +176,7 @@ Search::prepare ()
exit (1); exit (1);
} }
} }
}
/* Determine whether the hash function shall include the length. */ /* Determine whether the hash function shall include the length. */
_hash_includes_len = !(option[NOLENGTH] || (_min_key_len == _max_key_len)); _hash_includes_len = !(option[NOLENGTH] || (_min_key_len == _max_key_len));
@@ -413,8 +415,10 @@ Search::find_positions ()
for (int i1 = imax; i1 >= -1; i1--) for (int i1 = imax; i1 >= -1; i1--)
if (current.contains (i1) && !mandatory.contains (i1)) if (current.contains (i1) && !mandatory.contains (i1))
{
for (int i2 = imax; i2 >= -1; i2--) for (int i2 = imax; i2 >= -1; i2--)
if (current.contains (i2) && !mandatory.contains (i2) && i2 != i1) if (current.contains (i2) && !mandatory.contains (i2) && i2 != i1)
{
for (int i3 = imax; i3 >= 0; i3--) for (int i3 = imax; i3 >= 0; i3--)
if (!current.contains (i3)) if (!current.contains (i3))
{ {
@@ -425,9 +429,10 @@ Search::find_positions ()
unsigned int try_duplicates_count = unsigned int try_duplicates_count =
count_duplicates_tuple (tryal, alpha_unify); count_duplicates_tuple (tryal, alpha_unify);
/* We prefer 'try' to 'best' if it produces less duplicates, /* We prefer 'try' to 'best' if it produces less
or if it produces the same number of duplicates but with duplicates, or if it produces the same number
a more efficient hash function. */ of duplicates but with a more efficient hash
function. */
if (try_duplicates_count < best_duplicates_count if (try_duplicates_count < best_duplicates_count
|| (try_duplicates_count == best_duplicates_count || (try_duplicates_count == best_duplicates_count
&& (i1 == -1 || i2 == -1 || i3 >= 0))) && (i1 == -1 || i2 == -1 || i3 >= 0)))
@@ -436,6 +441,8 @@ Search::find_positions ()
best_duplicates_count = try_duplicates_count; best_duplicates_count = try_duplicates_count;
} }
} }
}
}
/* Stop removing positions when it gives no improvement. */ /* Stop removing positions when it gives no improvement. */
if (best_duplicates_count > current_duplicates_count) if (best_duplicates_count > current_duplicates_count)
@@ -1636,9 +1643,11 @@ Search::optimize ()
/* Propagate unified asso_values. */ /* Propagate unified asso_values. */
if (_alpha_unify) if (_alpha_unify)
{
for (unsigned int c = 0; c < _alpha_size; c++) for (unsigned int c = 0; c < _alpha_size; c++)
if (_alpha_unify[c] != c) if (_alpha_unify[c] != c)
_asso_values[c] = _asso_values[_alpha_unify[c]]; _asso_values[c] = _asso_values[_alpha_unify[c]];
}
} }
/* Prints out some diagnostics upon completion. */ /* Prints out some diagnostics upon completion. */