summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2002-11-19 12:55:48 +0000
committerBruno Haible <bruno@clisp.org>2002-11-19 12:55:48 +0000
commit2cd11405ed0a30b01789466132fec6b6605ab25a (patch)
treef1becd5a17576864b7e7fe19c2402807b0510be0 /src
parent4cda19576bacc02b1ee7f6306ed5c935ac9ad828 (diff)
downloadgperf-2cd11405ed0a30b01789466132fec6b6605ab25a.tar.gz
Start using bool.
Diffstat (limited to 'src')
-rw-r--r--src/bool-array.h5
-rw-r--r--src/bool-array.icc9
-rw-r--r--src/gen-perf.cc6
-rw-r--r--src/gen-perf.h2
-rw-r--r--src/hash-table.cc2
-rw-r--r--src/hash-table.h4
-rw-r--r--src/input.cc2
-rw-r--r--src/input.h2
-rw-r--r--src/key-list.cc18
-rw-r--r--src/key-list.h10
-rw-r--r--src/options.h8
-rw-r--r--src/options.icc12
-rw-r--r--src/output.cc20
-rw-r--r--src/output.h4
14 files changed, 53 insertions, 51 deletions
diff --git a/src/bool-array.h b/src/bool-array.h
index b81d162..3651173 100644
--- a/src/bool-array.h
+++ b/src/bool-array.h
@@ -46,8 +46,9 @@ public:
/* Resets all bits to zero. */
void clear ();
- /* Sets the specified bit to one. Returns its previous value (0 or 1). */
- int set_bit (unsigned int index);
+ /* Sets the specified bit to true.
+ Returns its previous value (false or true). */
+ bool set_bit (unsigned int index);
private:
/* Size of array. */
diff --git a/src/bool-array.icc b/src/bool-array.icc
index 6a41cdf..bc85076 100644
--- a/src/bool-array.icc
+++ b/src/bool-array.icc
@@ -38,18 +38,19 @@ Bool_Array::Bool_Array (unsigned int size)
_size, (unsigned int) (_size * sizeof (_storage_array[0])));
}
-/* Sets the specified bit to one. Returns its previous value (0 or 1). */
-INLINE int
+/* Sets the specified bit to true.
+ Returns its previous value (false or true). */
+INLINE bool
Bool_Array::set_bit (unsigned int index)
{
if (_storage_array[index] == _iteration_number)
/* The bit was set since the last clear() call. */
- return 1;
+ return true;
else
{
/* The last operation on this bit was clear(). Set it now. */
_storage_array[index] = _iteration_number;
- return 0;
+ return false;
}
}
diff --git a/src/gen-perf.cc b/src/gen-perf.cc
index a90994d..cdd62a6 100644
--- a/src/gen-perf.cc
+++ b/src/gen-perf.cc
@@ -168,7 +168,7 @@ Gen_Perf::hash (KeywordExt *key_node)
that all legal Asso_Values are visited without repetition since
Option.Get_Jump was forced to be an odd value! */
-inline int
+inline bool
Gen_Perf::affects_prev (char c, KeywordExt *curr)
{
int original_char = _asso_values[(unsigned char)c];
@@ -202,7 +202,7 @@ Gen_Perf::affects_prev (char c, KeywordExt *curr)
_fewest_collisions = collisions;
if (option[DEBUG])
fprintf (stderr, "- resolved after %d iterations", total_iterations - i);
- return 0;
+ return false;
}
}
}
@@ -210,7 +210,7 @@ Gen_Perf::affects_prev (char c, KeywordExt *curr)
/* Restore original values, no more tries. */
_asso_values[(unsigned char)c] = original_char;
/* If we're this far it's time to try the next character.... */
- return 1;
+ return true;
}
/* Change a character value, try least-used characters first. */
diff --git a/src/gen-perf.h b/src/gen-perf.h
index 80f0f42..7443daa 100644
--- a/src/gen-perf.h
+++ b/src/gen-perf.h
@@ -37,7 +37,7 @@ private:
Bool_Array * _collision_detector;
void change (KeywordExt *prior, KeywordExt *curr);
- int affects_prev (char c, KeywordExt *curr);
+ bool affects_prev (char c, KeywordExt *curr);
static int hash (KeywordExt *key_node);
static int compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3);
static void sort_set (char *union_set, int len);
diff --git a/src/hash-table.cc b/src/hash-table.cc
index 26be5fa..8830cb6 100644
--- a/src/hash-table.cc
+++ b/src/hash-table.cc
@@ -34,7 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
This compromises information hiding somewhat, but greatly reduces
memory fragmentation, since we can now use alloca! */
-Hash_Table::Hash_Table (KeywordExt **table_ptr, int s, int ignore_len):
+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));
diff --git a/src/hash-table.h b/src/hash-table.h
index 0f3a95c..0e94239 100644
--- a/src/hash-table.h
+++ b/src/hash-table.h
@@ -32,10 +32,10 @@ private:
KeywordExt ** _table; /* Vector of pointers to linked lists of keywords. */
int _size; /* Size of the vector. */
int _collisions; /* Find out how well our double hashing is working! */
- int _ignore_length;
+ bool _ignore_length;
public:
- Hash_Table (KeywordExt **t, int s, int ignore_len);
+ Hash_Table (KeywordExt **t, int s, bool ignore_len);
~Hash_Table ();
KeywordExt * insert (KeywordExt *item);
};
diff --git a/src/input.cc b/src/input.cc
index 1d18210..d57abde 100644
--- a/src/input.cc
+++ b/src/input.cc
@@ -343,5 +343,5 @@ Input::read_keys ()
/* See if any additional C code is included at end of this file. */
if (ptr)
- _additional_code = 1;
+ _additional_code = true;
}
diff --git a/src/input.h b/src/input.h
index d7e8247..583bcb8 100644
--- a/src/input.h
+++ b/src/input.h
@@ -45,7 +45,7 @@ public:
const char * _return_type; /* Pointer to return type for lookup function. */
const char * _struct_tag; /* Shorthand for user-defined struct tag type. */
const char * _include_src; /* C source code to be included verbatim. */
- int _additional_code; /* True if any additional C code is included. */
+ bool _additional_code; /* True if any additional C code is included. */
KeywordExt_List * _head; /* Points to the head of the linked list. */
};
diff --git a/src/key-list.cc b/src/key-list.cc
index 81db2ac..c1ff2cd 100644
--- a/src/key-list.cc
+++ b/src/key-list.cc
@@ -32,7 +32,7 @@ static const int TABLE_MULTIPLE = 10;
/* Efficiently returns the least power of two greater than or equal to X! */
#define POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X)))
-int Key_List::_determined[MAX_ALPHA_SIZE];
+bool Key_List::_determined[MAX_ALPHA_SIZE];
/* Destructor dumps diagnostics during debugging. */
@@ -232,15 +232,15 @@ 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)] = 1;
+ _determined[(unsigned char)(*p)] = true;
}
/* Returns TRUE if PTR's key set is already completely determined. */
-inline int
+inline bool
Key_List::already_determined (KeywordExt *ptr)
{
- int is_determined = 1;
+ bool is_determined = true;
const char *p = ptr->_selchars;
unsigned int i = ptr->_selchars_length;
@@ -267,8 +267,8 @@ Key_List::reorder ()
keyword->_occurrence = get_occurrence (keyword);
}
- _hash_sort = 0;
- _occurrence_sort = 1;
+ _hash_sort = false;
+ _occurrence_sort = true;
_head = merge_sort (_head);
@@ -302,8 +302,8 @@ Key_List::reorder ()
void
Key_List::sort ()
{
- _hash_sort = 1;
- _occurrence_sort = 0;
+ _hash_sort = true;
+ _occurrence_sort = false;
_head = merge_sort (_head);
}
@@ -337,7 +337,7 @@ Key_List::Key_List ()
_struct_tag = 0;
_head = 0;
_total_duplicates = 0;
- _additional_code = 0;
+ _additional_code = false;
}
/* Returns the length of entire key list. */
diff --git a/src/key-list.h b/src/key-list.h
index a09fa1a..b1459a0 100644
--- a/src/key-list.h
+++ b/src/key-list.h
@@ -43,19 +43,19 @@ protected:
int _max_key_len; /* Maximum length of the longest keyword. */
int _min_key_len; /* Minimum length of the shortest keyword. */
private:
- int _occurrence_sort; /* True if sorting by occurrence. */
- int _hash_sort; /* True if sorting by hash value. */
+ bool _occurrence_sort; /* True if sorting by occurrence. */
+ bool _hash_sort; /* True if sorting by hash value. */
protected:
- int _additional_code; /* True if any additional C code is included. */
+ bool _additional_code; /* True if any additional C code is included. */
private:
int _list_len; /* Length of head's Key_List, not counting duplicates. */
protected:
int _total_keys; /* Total number of keys, counting duplicates. */
int _size; /* Range of the hash table. */
private:
- static int _determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
+ static bool _determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
static int get_occurrence (KeywordExt *ptr);
- static int already_determined (KeywordExt *ptr);
+ static bool already_determined (KeywordExt *ptr);
static void set_determined (KeywordExt *ptr);
void dump ();
KeywordExt_List * merge (KeywordExt_List *list1, KeywordExt_List *list2);
diff --git a/src/options.h b/src/options.h
index 1ea6a15..479cc08 100644
--- a/src/options.h
+++ b/src/options.h
@@ -127,8 +127,8 @@ public:
void set_size (unsigned int size);
/* Sorts the array in reverse order.
- Returns 1 if there are no duplicates, 0 otherwise. */
- int sort ();
+ Returns true if there are no duplicates, false otherwise. */
+ bool sort ();
private:
/* Number of positions, excluding the terminating PositionIterator::EOS. */
@@ -176,8 +176,8 @@ public:
/* Accessors. */
- /* Tests a given boolean option. Returns 1 if set, 0 otherwise. */
- int operator[] (Option_Type option) const;
+ /* Tests a given boolean option. Returns true if set, false otherwise. */
+ bool operator[] (Option_Type option) const;
/* Returns the iterations value. */
int get_iterations () const;
diff --git a/src/options.icc b/src/options.icc
index eef1687..7479750 100644
--- a/src/options.icc
+++ b/src/options.icc
@@ -68,12 +68,12 @@ Positions::set_size (unsigned int size)
}
/* Sorts the array in reverse order.
- Returns 1 if there are no duplicates, 0 otherwise. */
-INLINE int
+ Returns true if there are no duplicates, false otherwise. */
+INLINE bool
Positions::sort ()
{
/* Bubble sort. */
- int duplicate_free = 1;
+ bool duplicate_free = true;
unsigned char *base = _positions;
unsigned int len = _size;
@@ -84,7 +84,7 @@ Positions::sort ()
for (j = i, tmp = base[j]; j > 0 && tmp >= base[j - 1]; j--)
if ((base[j] = base[j - 1]) == tmp) /* oh no, a duplicate!!! */
- duplicate_free = 0;
+ duplicate_free = false;
base[j] = tmp;
}
@@ -105,8 +105,8 @@ PositionIterator::next ()
return _set._positions[_index++];
}
-/* Tests a given boolean option. Returns 1 if set, 0 otherwise. */
-INLINE int
+/* Tests a given boolean option. Returns true if set, false otherwise. */
+INLINE bool
Options::operator[] (Option_Type option) const
{
return _option_word & option;
diff --git a/src/output.cc b/src/output.cc
index ad5ae88..b2498c0 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -65,16 +65,16 @@ static const char *char_to_index;
/* ------------------------------------------------------------------------- */
/* Constructor. */
-Output::Output (KeywordExt_List *head_, const char *array_type_,
- const char *return_type_, const char *struct_tag_,
- int additional_code_, const char *include_src_,
- int total_keys_, int total_duplicates_, int max_key_len_,
- int min_key_len_, Vectors *v_)
- : _head (head_), _array_type (array_type_), _return_type (return_type_),
- _struct_tag (struct_tag_), _additional_code (additional_code_),
- _include_src (include_src_), _total_keys (total_keys_),
- _total_duplicates (total_duplicates_), _max_key_len (max_key_len_),
- _min_key_len (min_key_len_), _v (v_)
+Output::Output (KeywordExt_List *head, const char *array_type,
+ const char *return_type, const char *struct_tag,
+ bool additional_code, const char *include_src,
+ int total_keys, int total_duplicates, int max_key_len,
+ int min_key_len, Vectors *v)
+ : _head (head), _array_type (array_type), _return_type (return_type),
+ _struct_tag (struct_tag), _additional_code (additional_code),
+ _include_src (include_src), _total_keys (total_keys),
+ _total_duplicates (total_duplicates), _max_key_len (max_key_len),
+ _min_key_len (min_key_len), _v (v)
{
}
diff --git a/src/output.h b/src/output.h
index e63a569..79c881d 100644
--- a/src/output.h
+++ b/src/output.h
@@ -34,7 +34,7 @@ struct Output_Compare;
class Output
{
public:
- Output (KeywordExt_List *head, const char *array_type, const char *return_type, const char *struct_tag, int additional_code, const char *include_src, int total_keys, int total_duplicates, int max_key_len, int min_key_len, Vectors *v);
+ Output (KeywordExt_List *head, const char *array_type, const char *return_type, const char *struct_tag, bool additional_code, const char *include_src, int total_keys, int total_duplicates, int max_key_len, int min_key_len, Vectors *v);
void output ();
private:
void compute_min_max ();
@@ -58,7 +58,7 @@ private:
/* Shorthand for user-defined struct tag type. */
const char * _struct_tag;
/* True if any additional C code is included. */
- int _additional_code;
+ bool _additional_code;
/* C source code to be included verbatim. */
const char * _include_src;
/* Total number of keys, counting duplicates. */