summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-03-03 14:28:09 +0000
committerBruno Haible <bruno@clisp.org>2003-03-03 14:28:09 +0000
commit9fa3ac42b377a7a8c519d64e25cbe83c7d3300a6 (patch)
tree5c8094a1c3fbea42dd6328fc89837d5df8475426
parentea37cea17b7ec6904823efbfd75fef85b31266ea (diff)
downloadgperf-9fa3ac42b377a7a8c519d64e25cbe83c7d3300a6.tar.gz
Portability fixes.
-rw-r--r--ChangeLog16
-rw-r--r--src/bool-array.cc2
-rw-r--r--src/hash-table.cc10
-rw-r--r--src/input.cc6
-rw-r--r--src/keyword.cc2
-rw-r--r--src/main.cc6
-rw-r--r--src/positions.h6
-rw-r--r--src/search.cc2
8 files changed, 34 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 32ef88f..2ea96ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2002-12-04 Bruno Haible <bruno@clisp.org>
+
+ Portability fixes.
+ * src/positions.h (Positions::LASTCHAR, Positions::MAX_KEY_POS,
+ PositionIterator::EOS): Define as compile-time constants using enum.
+ * src/bool-array.cc (Bool_Array::~Bool_Array): Remove const qualifier
+ of pointer to be deleted.
+ * src/input.cc (Input::~Input): Likewise.
+ * src/keyword.cc (KeywordExt::delete_selchars): Likewise.
+ * src/main.cc (main): Likewise.
+ * src/hash-table.cc (Hash_Table::~Hash_Table): Limit scope of 'for'
+ variables.
+ * src/search.cc (Search::prepare_asso_values): Use a static_cast to
+ convert from time_t to long. This is possible because ISO C 99 says
+ time_t is a numeric type.
+
2002-11-20 Bruno Haible <bruno@clisp.org>
* src/search.cc (Search::find_asso_values): Avoid gcc warnings about
diff --git a/src/bool-array.cc b/src/bool-array.cc
index a10f22d..330ca17 100644
--- a/src/bool-array.cc
+++ b/src/bool-array.cc
@@ -35,7 +35,7 @@ Bool_Array::~Bool_Array ()
fprintf (stderr, "\ndumping boolean array information\n"
"size = %d\niteration number = %d\nend of array dump\n",
_size, _iteration_number);
- delete[] _storage_array;
+ delete[] const_cast<unsigned int *>(_storage_array);
}
#ifndef __OPTIMIZE__
diff --git a/src/hash-table.cc b/src/hash-table.cc
index 6a2be7c..e00a456 100644
--- a/src/hash-table.cc
+++ b/src/hash-table.cc
@@ -90,10 +90,12 @@ Hash_Table::~Hash_Table ()
int field_width;
field_width = 0;
- for (int i = _size - 1; i >= 0; i--)
- if (_table[i])
- if (field_width < _table[i]->_selchars_length)
- field_width = _table[i]->_selchars_length;
+ {
+ for (int i = _size - 1; i >= 0; i--)
+ if (_table[i])
+ if (field_width < _table[i]->_selchars_length)
+ field_width = _table[i]->_selchars_length;
+ }
fprintf (stderr,
"\ndumping the hash table\n"
diff --git a/src/input.cc b/src/input.cc
index fbb0bea..3c81ba4 100644
--- a/src/input.cc
+++ b/src/input.cc
@@ -915,8 +915,8 @@ Input::read_input ()
Input::~Input ()
{
/* Free allocated memory. */
- delete[] _return_type;
- delete[] _struct_tag;
- delete[] _struct_decl;
+ delete[] const_cast<char*>(_return_type);
+ delete[] const_cast<char*>(_struct_tag);
+ delete[] const_cast<char*>(_struct_decl);
delete[] _input;
}
diff --git a/src/keyword.cc b/src/keyword.cc
index 36cfa6d..a784e07 100644
--- a/src/keyword.cc
+++ b/src/keyword.cc
@@ -130,7 +130,7 @@ KeywordExt::init_selchars_multiset (bool use_all_chars, const Positions& positio
void
KeywordExt::delete_selchars ()
{
- delete[] _selchars;
+ delete[] const_cast<unsigned int *>(_selchars);
}
diff --git a/src/main.cc b/src/main.cc
index 9878a3b..ec772c8 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -134,12 +134,12 @@ main (int argc, char *argv[])
do
{
KeywordExt *next_keyword = keyword->_duplicate_link;
- delete[] keyword->_selchars;
+ delete[] const_cast<unsigned int *>(keyword->_selchars);
if (keyword->_rest != empty_string)
- delete[] keyword->_rest;
+ delete[] const_cast<char*>(keyword->_rest);
if (!(keyword->_allchars >= inputter._input
&& keyword->_allchars < inputter._input_end))
- delete[] keyword->_allchars;
+ delete[] const_cast<char*>(keyword->_allchars);
delete keyword;
keyword = next_keyword;
}
diff --git a/src/positions.h b/src/positions.h
index 78f57c5..88d9584 100644
--- a/src/positions.h
+++ b/src/positions.h
@@ -33,11 +33,11 @@ class Positions
friend class PositionIterator;
public:
/* Denotes the last char of a keyword, depending on the keyword's length. */
- static const int LASTCHAR = 0;
+ enum { LASTCHAR = 0 };
/* Maximum key position specifiable by the user.
Note that this must fit into the element type of _positions[], below. */
- static const int MAX_KEY_POS = 255;
+ enum { MAX_KEY_POS = 255 };
/* Constructors. */
Positions ();
@@ -89,7 +89,7 @@ public:
PositionIterator (Positions const& positions);
/* End of iteration marker. */
- static const int EOS = -1;
+ enum { EOS = -1 };
/* Retrieves the next position, or EOS past the end. */
int next ();
diff --git a/src/search.cc b/src/search.cc
index 08d0a9f..5308690 100644
--- a/src/search.cc
+++ b/src/search.cc
@@ -778,7 +778,7 @@ Search::prepare_asso_values ()
if (option[RANDOM] || option.get_jump () == 0)
/* We will use rand(), so initialize the random number generator. */
- srand (reinterpret_cast<long>(time (0)));
+ srand (static_cast<long>(time (0)));
_initial_asso_value = (option[RANDOM] ? -1 : option.get_initial_asso_value ());
_jump = option.get_jump ();