mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Avoid g++ -Wold-style-cast warnings.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,5 +1,15 @@
|
||||
2002-11-02 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
Avoid g++ -Wold-style-cast warnings.
|
||||
* src/bool-array.icc: Use new-style casts.
|
||||
* src/gen-perf.cc: Likewise.
|
||||
* src/input.cc: Likewise.
|
||||
* src/key-list.cc: Likewise.
|
||||
* src/keyword.cc: Likewise.
|
||||
* src/options.cc: Likewise.
|
||||
* src/output.cc: Likewise.
|
||||
* src/hash-table.cc: Likewise. Remove (char *) cast in memset argument.
|
||||
|
||||
* src/keyword-list.h (KeywordExt_List): Don't inherit from KeywordExt.
|
||||
(KeywordExt_List::KeywordExt_List): Take a KeywordExt* as argument.
|
||||
(KeywordExt_List::_car): New field.
|
||||
|
||||
@@ -35,7 +35,8 @@ Bool_Array::Bool_Array (unsigned int size)
|
||||
memset (_storage_array, 0, size * sizeof (_storage_array[0]));
|
||||
if (option[DEBUG])
|
||||
fprintf (stderr, "\nbool array size = %d, total bytes = %d\n",
|
||||
_size, (unsigned int) (_size * sizeof (_storage_array[0])));
|
||||
_size,
|
||||
static_cast<unsigned int> (_size * sizeof (_storage_array[0])));
|
||||
}
|
||||
|
||||
/* Sets the specified bit to true.
|
||||
|
||||
@@ -58,7 +58,7 @@ Gen_Perf::Gen_Perf ()
|
||||
|
||||
if (option[RANDOM])
|
||||
{
|
||||
srand ((long) time (0));
|
||||
srand (reinterpret_cast<long>(time (0)));
|
||||
|
||||
for (int i = 0; i < ALPHA_SIZE; i++)
|
||||
_asso_values[i] = (rand () & asso_value_max - 1);
|
||||
@@ -139,7 +139,7 @@ Gen_Perf::sort_set (char *union_set, int len)
|
||||
char tmp;
|
||||
|
||||
for (curr = i + 1, tmp = union_set[curr];
|
||||
curr > 0 && _occurrences[(unsigned char)tmp] < _occurrences[(unsigned char)(union_set[curr-1])];
|
||||
curr > 0 && _occurrences[static_cast<unsigned char>(tmp)] < _occurrences[static_cast<unsigned char>(union_set[curr-1])];
|
||||
curr--)
|
||||
union_set[curr] = union_set[curr - 1];
|
||||
|
||||
@@ -157,7 +157,7 @@ Gen_Perf::hash (KeywordExt *key_node)
|
||||
const char *p = key_node->_selchars;
|
||||
int i = key_node->_selchars_length;
|
||||
for (; i > 0; p++, i--)
|
||||
sum += _asso_values[(unsigned char)(*p)];
|
||||
sum += _asso_values[static_cast<unsigned char>(*p)];
|
||||
|
||||
return key_node->_hash_value = sum;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ Gen_Perf::hash (KeywordExt *key_node)
|
||||
inline bool
|
||||
Gen_Perf::affects_prev (char c, KeywordExt *curr)
|
||||
{
|
||||
int original_char = _asso_values[(unsigned char)c];
|
||||
int original_char = _asso_values[static_cast<unsigned char>(c)];
|
||||
int total_iterations = !option[FAST]
|
||||
? get_asso_max () : option.get_iterations () ? option.get_iterations () : keyword_list_length ();
|
||||
|
||||
@@ -181,8 +181,8 @@ Gen_Perf::affects_prev (char c, KeywordExt *curr)
|
||||
{
|
||||
int collisions = 0;
|
||||
|
||||
_asso_values[(unsigned char)c] =
|
||||
(_asso_values[(unsigned char)c] + (option.get_jump () ? option.get_jump () : rand ()))
|
||||
_asso_values[static_cast<unsigned char>(c)] =
|
||||
(_asso_values[static_cast<unsigned char>(c)] + (option.get_jump () ? option.get_jump () : rand ()))
|
||||
& (get_asso_max () - 1);
|
||||
|
||||
/* Iteration Number array is a win, O(1) intialization time! */
|
||||
@@ -208,7 +208,7 @@ Gen_Perf::affects_prev (char c, KeywordExt *curr)
|
||||
}
|
||||
|
||||
/* Restore original values, no more tries. */
|
||||
_asso_values[(unsigned char)c] = original_char;
|
||||
_asso_values[static_cast<unsigned char>(c)] = original_char;
|
||||
/* If we're this far it's time to try the next character.... */
|
||||
return true;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ Gen_Perf::change (KeywordExt *prior, KeywordExt *curr)
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, " by changing asso_value['%c'] (char #%d) to %d\n",
|
||||
*p, p - union_set + 1, _asso_values[(unsigned char)(*p)]);
|
||||
*p, p - union_set + 1, _asso_values[static_cast<unsigned char>(*p)]);
|
||||
fflush (stderr);
|
||||
}
|
||||
return; /* Good, doesn't affect previous hash values, we'll take it. */
|
||||
|
||||
@@ -37,7 +37,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
Hash_Table::Hash_Table (KeywordExt **table_ptr, int s, bool ignore_len):
|
||||
_table (table_ptr), _size (s), _collisions (0), _ignore_length (ignore_len)
|
||||
{
|
||||
memset ((char *) _table, 0, _size * sizeof (*_table));
|
||||
memset (_table, 0, _size * sizeof (*_table));
|
||||
}
|
||||
|
||||
Hash_Table::~Hash_Table ()
|
||||
@@ -61,8 +61,8 @@ Hash_Table::~Hash_Table ()
|
||||
"\ndumping the hash table\n"
|
||||
"total available table slots = %d, total bytes = %d, total collisions = %d\n"
|
||||
"location, %*s, keyword\n",
|
||||
_size, _size * (int) sizeof (*_table), _collisions,
|
||||
field_width, "keysig");
|
||||
_size, _size * static_cast<unsigned int>(sizeof (*_table)),
|
||||
_collisions, field_width, "keysig");
|
||||
|
||||
for (int i = _size - 1; i >= 0; i--)
|
||||
if (_table[i])
|
||||
|
||||
@@ -217,7 +217,7 @@ parse_line (const char *line, const char *delimiters)
|
||||
}
|
||||
if (code > UCHAR_MAX)
|
||||
fprintf (stderr, "octal escape out of range: %s\n", line);
|
||||
*kp = (char) code;
|
||||
*kp = static_cast<char>(code);
|
||||
break;
|
||||
}
|
||||
case 'x':
|
||||
@@ -240,7 +240,7 @@ parse_line (const char *line, const char *delimiters)
|
||||
fprintf (stderr, "hexadecimal escape without any hex digits: %s\n", line);
|
||||
if (code > UCHAR_MAX)
|
||||
fprintf (stderr, "hexadecimal escape out of range: %s\n", line);
|
||||
*kp = (char) code;
|
||||
*kp = static_cast<char>(code);
|
||||
break;
|
||||
}
|
||||
case '\\': case '\'': case '"':
|
||||
|
||||
@@ -218,7 +218,7 @@ Key_List::get_occurrence (KeywordExt *ptr)
|
||||
const char *p = ptr->_selchars;
|
||||
unsigned int i = ptr->_selchars_length;
|
||||
for (; i > 0; p++, i--)
|
||||
value += _occurrences[(unsigned char)(*p)];
|
||||
value += _occurrences[static_cast<unsigned char>(*p)];
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ Key_List::set_determined (KeywordExt *ptr)
|
||||
const char *p = ptr->_selchars;
|
||||
unsigned int i = ptr->_selchars_length;
|
||||
for (; i > 0; p++, i--)
|
||||
_determined[(unsigned char)(*p)] = true;
|
||||
_determined[static_cast<unsigned char>(*p)] = true;
|
||||
}
|
||||
|
||||
/* Returns TRUE if PTR's key set is already completely determined. */
|
||||
@@ -245,7 +245,7 @@ Key_List::already_determined (KeywordExt *ptr)
|
||||
const char *p = ptr->_selchars;
|
||||
unsigned int i = ptr->_selchars_length;
|
||||
for (; is_determined && i > 0; p++, i--)
|
||||
is_determined = _determined[(unsigned char)(*p)];
|
||||
is_determined = _determined[static_cast<unsigned char>(*p)];
|
||||
|
||||
return is_determined;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void KeywordExt::init_selchars (Vectors *v)
|
||||
if (option[ALLCHARS])
|
||||
/* Use all the character positions in the KEY. */
|
||||
for (int i = _allchars_length; i > 0; k++, ptr++, i--)
|
||||
v->_occurrences[(unsigned char)(*ptr = *k)]++;
|
||||
v->_occurrences[static_cast<unsigned char>(*ptr = *k)]++;
|
||||
else
|
||||
/* Only use those character positions specified by the user. */
|
||||
{
|
||||
@@ -88,7 +88,7 @@ void KeywordExt::init_selchars (Vectors *v)
|
||||
else
|
||||
/* Out of range of KEY length, so we'll just skip it. */
|
||||
continue;
|
||||
v->_occurrences[(unsigned char)*ptr]++;
|
||||
v->_occurrences[static_cast<unsigned char>(*ptr)]++;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
|
||||
@@ -346,14 +346,14 @@ int PositionStringParser::nextPosition ()
|
||||
case '$': _str++; return _end_word_marker;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
for (_curr_value = 0; isdigit ((unsigned char)(*_str)); _str++)
|
||||
for (_curr_value = 0; isdigit (static_cast<unsigned char>(*_str)); _str++)
|
||||
_curr_value = _curr_value * 10 + (*_str - '0');
|
||||
|
||||
if (*_str == '-')
|
||||
{
|
||||
|
||||
for (_size = 1, _upper_bound = 0;
|
||||
isdigit ((unsigned char)(*++_str));
|
||||
isdigit (static_cast<unsigned char>(*++_str));
|
||||
_upper_bound = _upper_bound * 10 + (*_str - '0'));
|
||||
|
||||
if (_upper_bound <= _curr_value || _upper_bound > _high_bound)
|
||||
|
||||
@@ -217,7 +217,7 @@ output_string (const char *key, int len)
|
||||
putchar ('"');
|
||||
for (; len > 0; len--)
|
||||
{
|
||||
unsigned char c = (unsigned char) *key++;
|
||||
unsigned char c = static_cast<unsigned char>(*key++);
|
||||
if (isprint (c))
|
||||
{
|
||||
if (c == '"' || c == '\\')
|
||||
@@ -1020,7 +1020,7 @@ output_switches (KeywordExt_List *list, int num_switches, int size, int min_hash
|
||||
{
|
||||
int part1 = num_switches / 2;
|
||||
int part2 = num_switches - part1;
|
||||
int size1 = (int)((double)size / (double)num_switches * (double)part1 + 0.5);
|
||||
int size1 = static_cast<int>(static_cast<double>(size) / static_cast<double>(num_switches) * static_cast<double>(part1) + 0.5);
|
||||
int size2 = size - size1;
|
||||
|
||||
KeywordExt_List *temp = list;
|
||||
|
||||
Reference in New Issue
Block a user