mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Fix g++ -Wall warnings.
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -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,21 +160,23 @@ 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();
|
||||||
|
|
||||||
const char *k = keyword->_allchars;
|
const char *k = keyword->_allchars;
|
||||||
for (int i = keyword->_allchars_length; i > 0; k++, i--)
|
for (int i = keyword->_allchars_length; i > 0; k++, i--)
|
||||||
if (!(static_cast<unsigned char>(*k) < 128))
|
if (!(static_cast<unsigned char>(*k) < 128))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Option --seven-bit has been specified,\n"
|
fprintf (stderr, "Option --seven-bit has been specified,\n"
|
||||||
"but keyword \"%.*s\" contains non-ASCII characters.\n"
|
"but keyword \"%.*s\" contains non-ASCII characters.\n"
|
||||||
"Try removing option --seven-bit.\n",
|
"Try removing option --seven-bit.\n",
|
||||||
keyword->_allchars_length, keyword->_allchars);
|
keyword->_allchars_length, keyword->_allchars);
|
||||||
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,29 +415,34 @@ 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--)
|
{
|
||||||
if (current.contains (i2) && !mandatory.contains (i2) && i2 != i1)
|
for (int i2 = imax; i2 >= -1; i2--)
|
||||||
for (int i3 = imax; i3 >= 0; i3--)
|
if (current.contains (i2) && !mandatory.contains (i2) && i2 != i1)
|
||||||
if (!current.contains (i3))
|
{
|
||||||
{
|
for (int i3 = imax; i3 >= 0; i3--)
|
||||||
Positions tryal = current;
|
if (!current.contains (i3))
|
||||||
tryal.remove (i1);
|
|
||||||
tryal.remove (i2);
|
|
||||||
tryal.add (i3);
|
|
||||||
unsigned int try_duplicates_count =
|
|
||||||
count_duplicates_tuple (tryal, alpha_unify);
|
|
||||||
|
|
||||||
/* We prefer 'try' to 'best' if it produces less duplicates,
|
|
||||||
or if it produces the same number of duplicates but with
|
|
||||||
a more efficient hash function. */
|
|
||||||
if (try_duplicates_count < best_duplicates_count
|
|
||||||
|| (try_duplicates_count == best_duplicates_count
|
|
||||||
&& (i1 == -1 || i2 == -1 || i3 >= 0)))
|
|
||||||
{
|
{
|
||||||
best = tryal;
|
Positions tryal = current;
|
||||||
best_duplicates_count = try_duplicates_count;
|
tryal.remove (i1);
|
||||||
|
tryal.remove (i2);
|
||||||
|
tryal.add (i3);
|
||||||
|
unsigned int try_duplicates_count =
|
||||||
|
count_duplicates_tuple (tryal, alpha_unify);
|
||||||
|
|
||||||
|
/* We prefer 'try' to 'best' if it produces less
|
||||||
|
duplicates, or if it produces the same number
|
||||||
|
of duplicates but with a more efficient hash
|
||||||
|
function. */
|
||||||
|
if (try_duplicates_count < best_duplicates_count
|
||||||
|
|| (try_duplicates_count == best_duplicates_count
|
||||||
|
&& (i1 == -1 || i2 == -1 || i3 >= 0)))
|
||||||
|
{
|
||||||
|
best = tryal;
|
||||||
|
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++)
|
{
|
||||||
if (_alpha_unify[c] != c)
|
for (unsigned int c = 0; c < _alpha_size; c++)
|
||||||
_asso_values[c] = _asso_values[_alpha_unify[c]];
|
if (_alpha_unify[c] != c)
|
||||||
|
_asso_values[c] = _asso_values[_alpha_unify[c]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prints out some diagnostics upon completion. */
|
/* Prints out some diagnostics upon completion. */
|
||||||
|
|||||||
Reference in New Issue
Block a user