summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-05-15 00:24:28 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-05-15 00:24:28 +0000
commit135d6bd08066172ba0c2c3fd78190375aa064b73 (patch)
tree3e778c06d7c68b5491da40547c16e29fac6648b2
parentbfaf2b1a49474e64f7ca107929da61819675408e (diff)
downloadATCD-135d6bd08066172ba0c2c3fd78190375aa064b73.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/orbsvcs/CosLifeCycle.idl98
-rw-r--r--ace/OS.h2
-rw-r--r--ace/OS.i25
-rw-r--r--ace/Task.cpp49
-rw-r--r--apps/gperf/ChangeLog4
-rw-r--r--apps/gperf/src/Bool_Array.h50
-rw-r--r--apps/gperf/src/Gen_Perf.cpp133
-rw-r--r--apps/gperf/src/Gen_Perf.h25
-rw-r--r--apps/gperf/src/Hash_Table.cpp22
-rw-r--r--apps/gperf/src/Hash_Table.h45
-rw-r--r--apps/gperf/src/Iterator.cpp22
-rw-r--r--apps/gperf/src/Iterator.h61
-rw-r--r--apps/gperf/src/Key_List.cpp359
-rw-r--r--apps/gperf/src/Key_List.h92
-rw-r--r--apps/gperf/src/List_Node.cpp89
-rw-r--r--apps/gperf/src/List_Node.h37
-rw-r--r--apps/gperf/src/Options.cpp528
-rw-r--r--apps/gperf/src/Options.h196
-rw-r--r--apps/gperf/src/Vectors.cpp25
-rw-r--r--apps/gperf/src/Vectors.h38
-rw-r--r--apps/gperf/src/Version.cpp21
-rw-r--r--apps/gperf/src/gperf.cpp55
-rw-r--r--apps/gperf/src/new.cpp74
-rw-r--r--examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp84
-rw-r--r--performance-tests/Synch-Benchmarks/synch_driver.cpp9
25 files changed, 1159 insertions, 984 deletions
diff --git a/TAO/orbsvcs/orbsvcs/CosLifeCycle.idl b/TAO/orbsvcs/orbsvcs/CosLifeCycle.idl
index 2ce70a64d0c..0f849676df4 100644
--- a/TAO/orbsvcs/orbsvcs/CosLifeCycle.idl
+++ b/TAO/orbsvcs/orbsvcs/CosLifeCycle.idl
@@ -14,99 +14,103 @@
// chapter 6.
// The life cycle service description can be downloaded from:
// ftp://www.omg.org/pub/docs/formal/97-12-13.pdf
-// The original IDL file can be downloaede from:
+// The original IDL file can be downloaded from:
// ftp://www.omg.org/pub/docs/formal/97-11-02.idl
//
// = AUTHOR
-// OMG and Torben Worm <tworm@cs.wustl.edu>
+// OMG, Torben Worm <tworm@cs.wustl.edu>, and Michael Kircher <mk1@cec.wustl.edu>
//
// ============================================================================
-
// OMG IDL for CosLifeCycle Module, page 6-10 in
// Includes the following interfaces:
// FactoryFinder, LifeCycleObject, GenericFactory
#include "CosNaming.idl"
-module CosLifeCycle{
+module CosLifeCycle
+{
// = TITLE
// CosLifeCycle
//
// = DESCRIPTION
// This idl file describes the life cycle service.
// The purpose of the life cycle service is to
- //
typedef CosNaming::Name Key;
typedef Object Factory;
typedef sequence <Factory> Factories;
- typedef struct NVP {
+
+ typedef struct NVP
+ {
CosNaming::Istring name;
any value;
} NameValuePair;
+
typedef sequence <NameValuePair> Criteria;
- exception NoFactory {
+ exception NoFactory
+ {
Key search_key;
};
exception NotCopyable { string reason; };
exception NotMovable { string reason; };
exception NotRemovable { string reason; };
- exception InvalidCriteria{
+ exception InvalidCriteria
+ {
Criteria invalid_criteria;
};
- exception CannotMeetCriteria {
+ exception CannotMeetCriteria
+ {
Criteria unmet_criteria;
};
- interface FactoryFinder {
- // = TITLE
- //
- // = DESCRIPTION
- //
- //
+ interface FactoryFinder
+ {
+ // = TITLE
+ // @@ Please fill in.
+ // = DESCRIPTION
+ // @@ Please fill in.
- Factories find_factories(in Key factory_key)
- raises(NoFactory);
- };
+ Factories find_factories (in Key factory_key)
+ raises (NoFactory);
+ };
- interface LifeCycleObject {
- // = TITLE
- //
- // = DESCRIPTION
- //
- //
+ interface LifeCycleObject
+ {
+ // = TITLE
+ // @@ Please fill in.
+ // = DESCRIPTION
+ // @@ Please fill in.
- LifeCycleObject copy(in FactoryFinder there,
- in Criteria the_criteria)
- raises(NoFactory, NotCopyable, InvalidCriteria, CannotMeetCriteria);
- void move(in FactoryFinder there,
- in Criteria the_criteria)
- raises(NoFactory, NotMovable, InvalidCriteria, CannotMeetCriteria);
- void remove()
- raises(NotRemovable);
- };
+ LifeCycleObject copy (in FactoryFinder there,
+ in Criteria the_criteria)
+ raises (NoFactory, NotCopyable, InvalidCriteria, CannotMeetCriteria);
+ void move (in FactoryFinder there,
+ in Criteria the_criteria)
+ raises (NoFactory, NotMovable, InvalidCriteria, CannotMeetCriteria);
+ void remove ()
+ raises (NotRemovable);
+ };
- interface GenericFactory {
- // = TITLE
- //
- // = DESCRIPTION
- //
- //
+ interface GenericFactory
+ {
+ // = TITLE
+ // @@ Please fill in.
+ // = DESCRIPTION
+ // @@ Please fill in.
- boolean supports(in Key k);
- Object create_object(in Key k,
- in Criteria the_criteria)
- raises (NoFactory, InvalidCriteria, CannotMeetCriteria);
- };
+ boolean supports (in Key k);
+ Object create_object (in Key k,
+ in Criteria the_criteria)
+ raises (NoFactory, InvalidCriteria, CannotMeetCriteria);
+ };
};
-
-
// Criteria, page 6-17:
/*
-typedef struct NVP {
+typedef struct NVP
+{
CosNaming::Istring name;
any value;
} NameValuePair;
diff --git a/ace/OS.h b/ace/OS.h
index ea3e3902a39..97b6d49bc60 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -4741,6 +4741,8 @@ public:
const char *s2);
static const char *strpbrk (const char *s1,
const char *s2);
+ static size_t strcspn (const char *s,
+ const char *reject);
static size_t strspn(const char *s1,
const char *s2);
static char *strstr (char *s,
diff --git a/ace/OS.i b/ace/OS.i
index c85c65364e6..29338cf4f65 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -1116,6 +1116,31 @@ ACE_OS::strcat (char *s, const char *t)
}
ACE_INLINE size_t
+ACE_OS::strcspn (const char *s, const char *reject)
+{
+#if !defined (ACE_HAS_WINCE)
+ // ACE_TRACE ("ACE_OS::strstr");
+ return ::strcspn (s, reject);
+#else
+ const char *scan;
+ const char *rej_scan;
+ int count = 0;
+
+ for (scan = s; *scan; scan++)
+ {
+
+ for (rej_scan = reject; *rej_scan; rej_scan++)
+ if (*scan == *rej_scan)
+ return count;
+
+ count++;
+ }
+
+ return count;
+#endif /* ACE_HAS_WINCE */
+}
+
+ACE_INLINE size_t
ACE_OS::strspn (const char *s, const char *t)
{
#if !defined (ACE_HAS_WINCE)
diff --git a/ace/Task.cpp b/ace/Task.cpp
index 9ef0bfed31c..90bc07423ce 100644
--- a/ace/Task.cpp
+++ b/ace/Task.cpp
@@ -95,32 +95,30 @@ ACE_Task_Base::activate (long flags,
if (thread_names == 0)
// thread names were not specified
- this->grp_id_ = this->thr_mgr_->spawn_n (
- n_threads,
- ACE_THR_FUNC (&ACE_Task_Base::svc_run),
- (void *) this,
- flags,
- priority,
- grp_id,
- task,
- thread_handles,
- stack,
- stack_size);
+ this->grp_id_ =
+ this->thr_mgr_->spawn_n (n_threads,
+ ACE_THR_FUNC (&ACE_Task_Base::svc_run),
+ (void *) this,
+ flags,
+ priority,
+ grp_id,
+ task,
+ thread_handles,
+ stack,
+ stack_size);
else
// thread names were specified
- this->grp_id_ = this->thr_mgr_->spawn_n (
- thread_names,
- n_threads,
- ACE_THR_FUNC (&ACE_Task_Base::svc_run),
- (void *) this,
- flags,
- priority,
- grp_id,
- stack,
- stack_size,
- thread_handles);
-
-
+ this->grp_id_ =
+ this->thr_mgr_->spawn_n (thread_names,
+ n_threads,
+ ACE_THR_FUNC (&ACE_Task_Base::svc_run),
+ (void *) this,
+ flags,
+ priority,
+ grp_id,
+ stack,
+ stack_size,
+ thread_handles);
if (this->grp_id_ == -1)
return -1;
else
@@ -138,8 +136,7 @@ ACE_Task_Base::activate (long flags,
ACE_UNUSED_ARG (stack);
ACE_UNUSED_ARG (stack_size);
ACE_UNUSED_ARG (thread_names);
- errno = EINVAL;
- return -1;
+ ACE_NOTSUP_RETURN (-1);
}
#endif /* ACE_MT_SAFE */
}
diff --git a/apps/gperf/ChangeLog b/apps/gperf/ChangeLog
index d0e86c82103..8ef222178ca 100644
--- a/apps/gperf/ChangeLog
+++ b/apps/gperf/ChangeLog
@@ -1,3 +1,7 @@
+Thu May 14 16:37:39 1998 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
+
+ * src: ACE'ifed most of the gperf source code, yow!
+
Sun Apr 14 14:31:10 1996 Douglas C. Schmidt (schmidt@tango.cs.wustl.edu)
* src: Changed things so that there's no longer any use of the
diff --git a/apps/gperf/src/Bool_Array.h b/apps/gperf/src/Bool_Array.h
index 0a2757dbc8e..d39b0e81cc4 100644
--- a/apps/gperf/src/Bool_Array.h
+++ b/apps/gperf/src/Bool_Array.h
@@ -1,47 +1,48 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Simple lookup table abstraction implemented as an Generation Number Array.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.*/
-/* Define and implement a simple boolean array abstraction,
- uses an Generation Numbering implementation to save on initialization time. */
-
-#ifndef bool_array_h
-#define bool_array_h 1
+#if !defined (BOOL_ARRAY_H)
+#define BOOL_ARRAY_H
#include "Options.h"
-#ifdef LO_CAL
-/* If we are on a memory diet then we'll only make these use a limited
- amount of storage space. */
+#if defined (LO_CAL)
+// If we are on a memory diet then we'll only make these use a limited
+// amount of storage space.
typedef u_short STORAGE_TYPE;
#else
typedef int STORAGE_TYPE;
-#endif
+#endif /* LO_CAL */
class Bool_Array
{
+ // = TITLE
+ // Efficient lookup table abstraction implemented as an Generation
+ // Number Array.
+ //
+ // = DESCRIPTION
+ // Uses an Generation Numbering implementation to save on
+ // initialization time.
public:
Bool_Array (void);
~Bool_Array (void);
@@ -61,5 +62,4 @@ private:
// Keep track of array size.
};
-
-#endif
+#endif /* BOOL_ARRAY_H */
diff --git a/apps/gperf/src/Gen_Perf.cpp b/apps/gperf/src/Gen_Perf.cpp
index 57418ccc047..346f357131b 100644
--- a/apps/gperf/src/Gen_Perf.cpp
+++ b/apps/gperf/src/Gen_Perf.cpp
@@ -1,37 +1,37 @@
-/* Provides high-level routines to manipulate the keywork list
// $Id$
- structures the code generation output.
+/* structures the code generation output.
Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "Vectors.h"
#include "Gen_Perf.h"
-/* Current release version. */
+// Current release version.
extern char *version_string;
-/* Reads input keys, possibly applies the reordering heuristic, sets
- the maximum associated value size (rounded up to the nearest power
- of 2), may initialize the associated values array, and determines
- the maximum hash table size. Note: using the random numbers is
- often helpful, though not as deterministic, of course! */
+// Reads input keys, possibly applies the reordering heuristic, sets
+// the maximum associated value size (rounded up to the nearest power
+// of 2), may initialize the associated values array, and determines
+// the maximum hash table size. Note: using the random numbers is
+// often helpful, though not as deterministic, of course!
Gen_Perf::Gen_Perf (void)
{
@@ -49,7 +49,7 @@ Gen_Perf::Gen_Perf (void)
asso_value_max = non_linked_length;
else if (asso_value_max > 0)
asso_value_max *= non_linked_length;
- else /* if (asso_value_max < 0) */
+ else // if (asso_value_max < 0)
asso_value_max = non_linked_length / -asso_value_max;
option.set_asso_max (ACE_POW (asso_value_max));
@@ -64,7 +64,7 @@ Gen_Perf::Gen_Perf (void)
{
int asso_value = option.initial_value ();
- if (asso_value) /* Initialize array if user requests non-zero default. */
+ if (asso_value) // Initialize array if user requests non-zero default.
for (int i = ALPHA_SIZE - 1; i >= 0; i--)
Vectors::asso_values[i] = asso_value & option.get_asso_max () - 1;
}
@@ -85,10 +85,10 @@ Gen_Perf::Gen_Perf (void)
non_linked_length, asso_value_max, max_hash_value);
}
-/* Merge two disjoint hash key multisets to form the ordered disjoint union of the sets.
- (In a multiset, an element can occur multiple times).
- Precondition: both set_1 and set_2 must be ordered. Returns the length
- of the combined set. */
+// Merge two disjoint hash key multisets to form the ordered disjoint
+// union of the sets. (In a multiset, an element can occur multiple
+// times). Precondition: both set_1 and set_2 must be
+// ordered. Returns the length of the combined set.
inline int
Gen_Perf::compute_disjoint_union (char *set_1, char *set_2, char *set_3)
@@ -119,10 +119,10 @@ Gen_Perf::compute_disjoint_union (char *set_1, char *set_2, char *set_3)
return set_3 - base;
}
-/* Sort the UNION_SET in increasing frequency of occurrence.
- This speeds up later processing since we may assume the resulting
- set (Set_3, in this case), is ordered. Uses insertion sort, since
- the UNION_SET is typically short. */
+// Sort the UNION_SET in increasing frequency of occurrence. This
+// speeds up later processing since we may assume the resulting set
+// (Set_3, in this case), is ordered. Uses insertion sort, since the
+// UNION_SET is typically short.
inline void
Gen_Perf::sort_set (char *union_set, int len)
@@ -142,7 +142,7 @@ Gen_Perf::sort_set (char *union_set, int len)
}
}
-/* Generate a key set's hash value. */
+// Generate a key set's hash value.
inline int
Gen_Perf::hash (List_Node *key_node)
@@ -155,11 +155,12 @@ Gen_Perf::hash (List_Node *key_node)
return key_node->hash_value = sum;
}
-/* Find out how character value change affects successfully hashed
- items. Returns FALSE if no other hash values are affected, else
- returns TRUE. Note that because Option.Get_Asso_Max is a power of
- two we can guarantee that all legal Vectors::Asso_Values are visited without
- repetition since Option.Get_Jump was forced to be an odd value! */
+// Find out how character value change affects successfully hash
+// items. Returns FALSE if no other hash values are affected, else
+// returns TRUE. Note that because Option.Get_Asso_Max is a power of
+// two we can guarantee that all legal Vectors::Asso_Values are
+// visited without repetition since Option.Get_Jump was forced to be
+// an odd value!
inline int
Gen_Perf::affects_prev (char c, List_Node *curr)
@@ -168,7 +169,7 @@ Gen_Perf::affects_prev (char c, List_Node *curr)
int total_iterations = !option[FAST]
? option.get_asso_max () : option.get_iterations () ? option.get_iterations () : this->key_list.keyword_list_length ();
- /* Try all legal associated values. */
+ // Try all legal associated values.
for (int i = total_iterations - 1; i >= 0; i--)
{
@@ -177,11 +178,11 @@ Gen_Perf::affects_prev (char c, List_Node *curr)
Vectors::asso_values[c] = Vectors::asso_values[c] + (option.get_jump () ? option.get_jump () : rand ())
& option.get_asso_max () - 1;
- /* Iteration Number array is a win, O(1) intialization time! */
+ // Iteration Number array is a win, O(1) intialization time!
this->char_search.reset ();
- /* See how this asso_value change affects previous keywords. If
- it does better than before we'll take it! */
+ // See how this asso_value change affects previous keywords. If
+ // it does better than before we'll take it!
for (List_Node *ptr = this->key_list.head;
!this->char_search.find (hash (ptr)) || ++collisions < fewest_collisions;
@@ -195,13 +196,13 @@ Gen_Perf::affects_prev (char c, List_Node *curr)
}
}
- /* Restore original values, no more tries. */
+ // Restore original values, no more tries.
Vectors::asso_values[c] = original_char;
- /* If we're this far it's time to try the next character.... */
+ // If we're this far it's time to try the next character....
return 1;
}
-/* Change a character value, try least-used characters first. */
+// Change a character value, try least-used characters first.
void
Gen_Perf::change (List_Node *prior, List_Node *curr)
@@ -219,7 +220,8 @@ Gen_Perf::change (List_Node *prior, List_Node *curr)
}
sort_set (union_set, compute_disjoint_union (prior->char_set, curr->char_set, union_set));
- /* Try changing some values, if change doesn't alter other values continue normal action. */
+ // Try changing some values, if change doesn't alter other values
+ // continue normal action.
fewest_collisions++;
for (char *temp = union_set; *temp; temp++)
@@ -231,7 +233,7 @@ Gen_Perf::change (List_Node *prior, List_Node *curr)
*temp, temp - union_set + 1, Vectors::asso_values[*temp]);
fflush (stderr);
}
- return; /* Good, doesn't affect previous hash values, we'll take it. */
+ return; // Good, doesn't affect previous hash values, we'll take it.
}
for (List_Node *ptr = this->key_list.head; ptr != curr; ptr = ptr->next)
@@ -248,21 +250,20 @@ Gen_Perf::change (List_Node *prior, List_Node *curr)
}
}
-/* Does the hard stuff....
- Initializes the Iteration Number array, and attempts to find a perfect
- function that will hash all the key words without getting any
- duplications. This is made much easier since we aren't attempting
- to generate *minimum* functions, only perfect ones.
- If we can't generate a perfect function in one pass *and* the user
- hasn't enabled the DUP option, we'll inform the user to try the
- randomization option, use -D, or choose alternative key positions.
- The alternatives (e.g., back-tracking) are too time-consuming, i.e,
- exponential in the number of keys. */
+// Does the hard stuff.... Initializes the Iteration Number array,
+// and attempts to find a perfect function that will hash all the key
+// words without getting any duplications. This is made much easier
+// since we aren't attempting to generate *minimum* functions, only
+// perfect ones. If we can't generate a perfect function in one pass
+// *and* the user hasn't enabled the DUP option, we'll inform the user
+// to try the randomization option, use -D, or choose alternative key
+// positions. The alternatives (e.g., back-tracking) are too
+// time-consuming, i.e, exponential in the number of keys.
int
Gen_Perf::generate (void)
{
-#if LARGE_STACK_ARRAYS
+#if defined (LARGE_STACK_ARRAYS)
STORAGE_TYPE buffer[max_hash_value + 1];
#else
// Note: we don't use new, because that invokes a custom operator new.
@@ -270,7 +271,7 @@ Gen_Perf::generate (void)
= (STORAGE_TYPE*) malloc (sizeof(STORAGE_TYPE) * (max_hash_value + 1));
if (buffer == NULL)
abort ();
-#endif
+#endif /* LARGE_STACK_ARRAYS */
this->char_search.init (buffer, max_hash_value + 1);
@@ -293,7 +294,8 @@ Gen_Perf::generate (void)
num_done++;
}
- /* Make one final check, just to make sure nothing weird happened.... */
+ // Make one final check, just to make sure nothing weird
+ // happened....
this->char_search.reset ();
@@ -301,31 +303,31 @@ Gen_Perf::generate (void)
curr;
curr = curr->next)
if (this->char_search.find (hash (curr)))
- if (option[DUP]) /* Keep track of this number... */
+ if (option[DUP]) // Keep track of this number...
this->key_list.total_duplicates++;
- else /* Yow, big problems. we're outta here! */
+ else // Yow, big problems. we're outta here!
{
ACE_ERROR ((LM_ERROR, "\nInternal error, duplicate value %d:\n"
"try options -D or -r, or use new key positions.\n\n", hash (curr)));
-#if !LARGE_STACK_ARRAYS
+#if !defined (LARGE_STACK_ARRAYS)
free (buffer);
-#endif
+#endif /* LARGE_STACK_ARRAYS */
return 1;
}
- /* Sorts the key word list by hash value, and then outputs the list.
- The generated hash table code is only output if the early stage of
- processing turned out O.K. */
+ // Sorts the key word list by hash value, and then outputs the list.
+ // The generated hash table code is only output if the early stage
+ // of processing turned out O.K.
this->key_list.sort ();
this->key_list.output ();
-#if !LARGE_STACK_ARRAYS
+#if !defined (LARGE_STACK_ARRAYS)
free (buffer);
-#endif
+#endif /* LARGE_STACK_ARRAYS */
return 0;
}
-/* Prints out some diagnostics upon completion. */
+// Prints out some diagnostics upon completion.
Gen_Perf::~Gen_Perf (void)
{
@@ -339,7 +341,6 @@ Gen_Perf::~Gen_Perf (void)
i, Vectors::asso_values[i], i, Vectors::occurrences[i]);
fprintf (stderr, "end table dumping\n");
-
}
}
diff --git a/apps/gperf/src/Gen_Perf.h b/apps/gperf/src/Gen_Perf.h
index 50d2ab95c0f..4bdfc5ba0fd 100644
--- a/apps/gperf/src/Gen_Perf.h
+++ b/apps/gperf/src/Gen_Perf.h
@@ -1,12 +1,7 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Provides high-level routines to manipulate the keyword list
- structures the code generation output.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
@@ -25,8 +20,8 @@ You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-#ifndef gen_perf_h
-#define gen_perf_h 1
+#if !defined (GEN_PERF_H)
+#define GEN_PERF_H
#include "Options.h"
#include "Key_List.h"
@@ -34,16 +29,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
class Gen_Perf
{
+ // = TITLE
+ // Provides high-level routines to manipulate the keyword list
+ // structures the code generation output.
public:
Gen_Perf (void);
~Gen_Perf (void);
int generate (void);
private:
- void change (List_Node *prior, List_Node *curr);
- int affects_prev (char c, List_Node *curr);
- static int hash (List_Node *key_node);
- static int compute_disjoint_union (char *set_1, char *set_2, char *set_3);
+ void change (List_Node *prior, List_Node *curr);
+ int affects_prev (char c, List_Node *curr);
+ static int hash (List_Node *key_node);
+ static int compute_disjoint_union (char *set_1, char *set_2, char *set_3);
static void sort_set (char *union_set, int len);
int max_hash_value;
@@ -62,4 +60,5 @@ private:
// List of the keys we're trying to map into a perfect hash
// function.
};
-#endif
+
+#endif /* GEN_PERF_H */
diff --git a/apps/gperf/src/Hash_Table.cpp b/apps/gperf/src/Hash_Table.cpp
index fa165715abc..3f5bbc258d0 100644
--- a/apps/gperf/src/Hash_Table.cpp
+++ b/apps/gperf/src/Hash_Table.cpp
@@ -1,24 +1,24 @@
-/* Hash table for checking keyword links. Implemented using double hashing.
// $Id$
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "ace/ACE.h"
#include "Hash_Table.h"
diff --git a/apps/gperf/src/Hash_Table.h b/apps/gperf/src/Hash_Table.h
index 80cba1e9e34..1890b0af467 100644
--- a/apps/gperf/src/Hash_Table.h
+++ b/apps/gperf/src/Hash_Table.h
@@ -1,40 +1,48 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Hash table used to check for duplicate keyword entries.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
-#ifndef hash_table_h
-#define hash_table_h 1
+#if !defined (HASH_TABLE_H)
+#define HASH_TABLE_H
#include "Options.h"
#include "List_Node.h"
+// @@ This class should be replaced by something in ACE, e.g.,
+// ACE_Hash_Map_Manager. Perhaps we should implement a new
+// ACE_Hash_Map that uses double hashing, however!
class Hash_Table
{
+ // = TITLE
+ // Hash table used to check for duplicate keyword entries.
+ //
+ // = DESCRIPTION
+ // This implementation uses "double hashing."
public:
- Hash_Table (List_Node **t, int s);
+ Hash_Table (List_Node **t,
+ int s);
+
~Hash_Table (void);
+
List_Node *operator () (List_Node *item, int ignore_length);
private:
@@ -47,4 +55,5 @@ private:
int collisions;
// Find out how well our double hashing is working!
};
-#endif
+
+#endif /* HASH_TABLE_H */
diff --git a/apps/gperf/src/Iterator.cpp b/apps/gperf/src/Iterator.cpp
index 94768115231..bfdd4c7f3e0 100644
--- a/apps/gperf/src/Iterator.cpp
+++ b/apps/gperf/src/Iterator.cpp
@@ -1,24 +1,24 @@
-/* Provides an Iterator for keyword characters.
// $Id$
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "Iterator.h"
diff --git a/apps/gperf/src/Iterator.h b/apps/gperf/src/Iterator.h
index d1fe416859d..0f5973d69d1 100644
--- a/apps/gperf/src/Iterator.h
+++ b/apps/gperf/src/Iterator.h
@@ -1,52 +1,57 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Provides an Iterator for keyword characters.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Provides an Iterator that expands and decodes a control string
- containing digits and ranges, returning an integer every time the
- generator function is called. This is used to decode the user's
- key position requests. For example: "-k 1,2,5-10,$" will return 1,
- 2, 5, 6, 7, 8, 9, 10, and 0 ( representing the abstract ``last
- character of the key'' on successive calls to the member function
- operator (). No errors are handled in these routines, they are
- passed back to the calling routines via a user-supplied Error_Value */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
-#ifndef iterator_h
-#define iterator_h 1
+#if !defined (ITERATOR_H)
+#define ITERATOR_H
#include "Options.h"
class Iterator
{
+ // = TITLE
+ // Provides an Iterator that expands and decodes a control string
+ // containing digits and ranges, returning an integer every time the
+ // generator function is called.
+ //
+ // = DESCRIPTION
+ // This class is used to decode the user's key position requests.
+ // For example: "-k 1,2,5-10,$" will return 1, 2, 5, 6, 7, 8, 9,
+ // 10, and 0 ( representing the abstract ``last character of the
+ // key'' on successive calls to the member function operator ().
+ // No errors are handled in these routines, they are passed back
+ // to the calling routines via a user-supplied Error_Value */
public:
- Iterator (char *s, int lo, int hi, int word_end, int bad_val, int key_end);
+ Iterator (char *s,
+ int lo,
+ int hi,
+ int word_end,
+ int bad_val,
+ int key_end);
int operator () (void);
private:
char *str;
- // A pointer to the string provided by the user.
+ // A pointer to the string provided by the user.
int end;
// Value returned after last key is processed.
@@ -64,4 +69,4 @@ private:
// Smallest possible value, inclusive.
};
-#endif
+#endif /* ITERATOR_H */
diff --git a/apps/gperf/src/Key_List.cpp b/apps/gperf/src/Key_List.cpp
index c1009b3441c..d749d8e03a6 100644
--- a/apps/gperf/src/Key_List.cpp
+++ b/apps/gperf/src/Key_List.cpp
@@ -1,71 +1,76 @@
-/* Routines for building, ordering, and printing the keyword list.
// $Id$
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "ace/Read_Buffer.h"
#include "Hash_Table.h"
#include "Vectors.h"
#include "Key_List.h"
-/* Make the hash table 10 times larger than the number of keyword entries. */
+// Make the hash table 10 times larger than the number of keyword entries.
static const int TABLE_MULTIPLE = 10;
-/* Default type for generated code. */
+// Default type for generated code.
static char *const default_array_type = "char *";
-/* in_word_set return type, by default. */
+// in_word_set return type, by default.
static char *const default_return_type = "char *";
-/* How wide the printed field width must be to contain the maximum hash value. */
+// How wide the printed field width must be to contain the maximum hash value.
static int field_width = 0;
static int determined[ALPHA_SIZE];
-/* Destructor dumps diagnostics during debugging. */
+// Destructor dumps diagnostics during debugging.
Key_List::~Key_List (void)
{
if (option[DEBUG])
{
- fprintf (stderr, "\nDumping key list information:\ntotal non-static linked keywords = %d"
+ fprintf (stderr,
+ "\nDumping key list information:\ntotal non-static linked keywords = %d"
"\ntotal keywords = %d\ntotal duplicates = %d\nmaximum key length = %d\n",
- list_len, total_keys, total_duplicates ? total_duplicates + 1 : 0, max_key_len);
+ list_len,
+ total_keys,
+ total_duplicates ? total_duplicates + 1 : 0,
+ max_key_len);
dump ();
ACE_ERROR ((LM_ERROR, "End dumping list.\n\n"));
}
}
-/* Gathers the input stream into a buffer until one of two things occur:
-
- 1. We read a '%' followed by a '%'
- 2. We read a '%' followed by a '}'
-
- The first symbolizes the beginning of the keyword list proper,
- The second symbolizes the end of the C source code to be generated
- verbatim in the output file.
-
- I assume that the keys are separated from the optional preceding struct
- declaration by a consecutive % followed by either % or } starting in
- the first column. The code below uses an expandible buffer to scan off
- and return a pointer to all the code (if any) appearing before the delimiter. */
+// Gathers the input stream into a buffer until one of two things occur:
+//
+// 1. We read a '%' followed by a '%'
+// 2. We read a '%' followed by a '}'
+//
+// The first symbolizes the beginning of the keyword list proper, The
+// second symbolizes the end of the C source code to be generated
+// verbatim in the output file.
+//
+// I assume that the keys are separated from the optional preceding
+// struct declaration by a consecutive % followed by either % or }
+// starting in the first column. The code below uses an expandible
+// buffer to scan off and return a pointer to all the code (if any)
+// appearing before the delimiter. */
char *
Key_List::get_special_input (char delimiter)
@@ -95,7 +100,7 @@ Key_List::get_special_input (char delimiter)
else
buf[i++] = '%';
}
- else if (i >= size) /* Yikes, time to grow the buffer! */
+ else if (i >= size) // Yikes, time to grow the buffer!
{
char *temp = new char[size *= 2];
int j;
@@ -108,11 +113,11 @@ Key_List::get_special_input (char delimiter)
buf[i] = c;
}
- return 0; /* Problem here. */
+ return 0; // Problem here.
}
-/* Stores any C text that must be included verbatim into the
- generated code output. */
+// Stores any C text that must be included verbatim into the generated
+// code output.
char *
Key_List::save_include_src (void)
@@ -122,15 +127,20 @@ Key_List::save_include_src (void)
if ((c = getchar ()) != '%')
ungetc (c, stdin);
else if ((c = getchar ()) != '{')
- ACE_ERROR ((LM_ERROR, "internal error, %c != '{' on line %d in file %s%a", c, __LINE__, __FILE__, 1));
+ ACE_ERROR ((LM_ERROR,
+ "internal error, %c != '{' on line %d in file %s%a",
+ c,
+ __LINE__,
+ __FILE__,
+ 1));
else
return get_special_input ('}');
return "";
}
-/* Determines from the input file whether the user wants to build a table
- from a user-defined struct, or whether the user is content to simply
- use the default array of keys. */
+// Determines from the input file whether the user wants to build a
+// table from a user-defined struct, or whether the user is content to
+// simply use the default array of keys.
char *
Key_List::get_array_type (void)
@@ -138,42 +148,19 @@ Key_List::get_array_type (void)
return get_special_input ('%');
}
-/* strcspn - find length of initial segment of S consisting entirely
- ANSI string package, when GNU libc comes out I'll replace this...). */
-
-inline int
-Key_List::strcspn (const char *s, const char *reject)
-{
- const char *scan;
- const char *rej_scan;
- int count = 0;
-
- for (scan = s; *scan; scan++)
- {
-
- for (rej_scan = reject; *rej_scan; rej_scan++)
- if (*scan == *rej_scan)
- return count;
-
- count++;
- }
-
- return count;
-}
-
-/* Sets up the Return_Type, the Struct_Tag type and the Array_Type
- based upon various user Options. */
+// Sets up the Return_Type, the Struct_Tag type and the Array_Type
+// based upon various user Options.
void
Key_List::set_output_types (void)
{
if (option[TYPE] && !(array_type = get_array_type ()))
- return; /* Something's wrong, bug we'll catch it later on.... */
- else if (option[TYPE]) /* Yow, we've got a user-defined type... */
+ return; // Something's wrong, bug we'll catch it later on....
+ else if (option[TYPE]) // Yow, we've got a user-defined type...
{
- int struct_tag_length = strcspn (array_type, "{\n\0");
+ int struct_tag_length = ACE_OS::strcspn (array_type, "{\n\0");
- if (option[POINTER]) /* And it must return a pointer... */
+ if (option[POINTER]) // And it must return a pointer...
{
return_type = new char[struct_tag_length + 2];
strncpy (return_type, array_type, struct_tag_length);
@@ -185,13 +172,14 @@ Key_List::set_output_types (void)
strncpy (struct_tag, array_type, struct_tag_length);
struct_tag[struct_tag_length] = '\0';
}
- else if (option[POINTER]) /* Return a char *. */
+ else if (option[POINTER]) // Return a char *.
return_type = default_array_type;
}
-/* Reads in all keys from standard input and creates a linked list pointed
- to by Head. This list is then quickly checked for ``links,'' i.e.,
- unhashable elements possessing identical key sets and lengths. */
+// Reads in all keys from standard input and creates a linked list
+// pointed to by Head. This list is then quickly checked for
+// ``links,'' i.e., unhashable elements possessing identical key sets
+// and lengths.
void
Key_List::read_keys (void)
@@ -208,32 +196,33 @@ Key_List::read_keys (void)
ACE_ERROR ((LM_ERROR, "No words in input file, did you forget to prepend %s"
" or use -t accidentally?\n%a", "%%", 1));
- /* Read in all the keywords from the input file. */
+ // Read in all the keywords from the input file.
else
{
const char *delimiter = option.get_delimiter ();
List_Node *temp, *trail = 0;
- head = new List_Node (ptr, strcspn (ptr, delimiter));
+ head = new List_Node (ptr, ACE_OS::strcspn (ptr, delimiter));
for (temp = head;
(ptr = input.read ('\n')) && strcmp (ptr, "%%");
temp = temp->next)
{
- temp->next = new List_Node (ptr, strcspn (ptr, delimiter));
+ temp->next = new List_Node (ptr, ACE_OS::strcspn (ptr, delimiter));
total_keys++;
}
- /* See if any additional source code is included at end of this file. */
+ // See if any additional source code is included at end of this file.
if (ptr)
additional_code = 1;
- /* Hash table this number of times larger than keyword number. */
+ // Hash table this number of times larger than keyword number.
int table_size = (list_len = total_keys) * TABLE_MULTIPLE;
-#if LARGE_STACK_ARRAYS
- /* By allocating the memory here we save on dynamic allocation overhead.
- Table must be a power of 2 for the hash function scheme to work. */
+#if defined (LARGE_STACK_ARRAYS)
+ // By allocating the memory here we save on dynamic allocation
+ // overhead. Table must be a power of 2 for the hash function
+ // scheme to work.
List_Node *table[ACE_POW (table_size)];
#else
// Note: we don't use new, because that invokes a custom operator new.
@@ -242,22 +231,23 @@ Key_List::read_keys (void)
List_Node **table = (List_Node**)malloc(malloc_size);
if (table == NULL)
abort ();
-#endif
+#endif /* LARGE_STACK_ARRAYS */
- /* Make large hash table for efficiency. */
+ // Make large hash table for efficiency.
Hash_Table found_link (table, table_size);
- /* Test whether there are any links and also set the maximum length of
+ // Test whether there are any links and also set the maximum length
an identifier in the keyword list. */
for (temp = head; temp; temp = temp->next)
{
List_Node *ptr = found_link (temp, option[NOLENGTH]);
- /* Check for links. We deal with these by building an equivalence class
- of all duplicate values (i.e., links) so that only 1 keyword is
- representative of the entire collection. This *greatly* simplifies
- processing during later stages of the program. */
+ // Check for links. We deal with these by building an
+ // equivalence class of all duplicate values (i.e., links)
+ // so that only 1 keyword is representative of the entire
+ // collection. This *greatly* simplifies processing during
+ // later stages of the program.
if (ptr)
{
@@ -267,7 +257,7 @@ Key_List::read_keys (void)
temp->link = ptr->link;
ptr->link = temp;
- /* Complain if user hasn't enabled the duplicate option. */
+ // Complain if user hasn't enabled the duplicate option.
if (!option[DUP] || option[DEBUG])
ACE_ERROR ((LM_ERROR, "Key link: \"%s\" = \"%s\", with key set \"%s\".\n",
temp->key, ptr->key, temp->char_set));
@@ -275,32 +265,36 @@ Key_List::read_keys (void)
else
trail = temp;
- /* Update minimum and maximum keyword length, if needed. */
+ // Update minimum and maximum keyword length, if needed.
if (max_key_len < temp->length)
max_key_len = temp->length;
if (min_key_len > temp->length)
min_key_len = temp->length;
}
-#if !LARGE_STACK_ARRAYS
+#if !defined (LARGE_STACK_ARRAYS)
free (table);
-#endif
+#endif /* LARGE_STACK_ARRAYS */
- /* Exit program if links exists and option[DUP] not set, since we can't continue */
+ // Exit program if links exists and option[DUP] not set, since
+ // we can't continue.
if (total_duplicates)
- ACE_ERROR ((LM_ERROR, option[DUP]
- ? "%d input keys have identical hash values, examine output carefully...\n"
- : "%d input keys have identical hash values,\ntry different key positions or use option -D.\n%a", total_duplicates, 1));
+ ACE_ERROR ((LM_ERROR,
+ option[DUP]
+ ? "%d input keys have identical hash values, examine output carefully...\n"
+ : "%d input keys have identical hash values,\ntry different key positions or use option -D.\n%a",
+ total_duplicates,
+ 1));
if (option[ALLCHARS])
option.set_keysig_size (max_key_len);
}
}
-/* Recursively merges two sorted lists together to form one sorted list. The
- ordering criteria is by frequency of occurrence of elements in the key set
- or by the hash value. This is a kludge, but permits nice sharing of
- almost identical code without incurring the overhead of a function
- call comparison. */
+// Recursively merges two sorted lists together to form one sorted
+// list. The ordering criteria is by frequency of occurrence of
+// elements in the key set or by the hash value. This is a kludge,
+// but permits nice sharing of almost identical code without incurring
+// the overhead of a function call comparison.
List_Node *
Key_List::merge (List_Node *list1, List_Node *list2)
@@ -322,8 +316,8 @@ Key_List::merge (List_Node *list1, List_Node *list2)
}
}
-/* Applies the merge sort algorithm to recursively sort the key list by
- frequency of occurrence of elements in the key set. */
+// Applies the merge sort algorithm to recursively sort the key list
+// by frequency of occurrence of elements in the key set.
List_Node *
Key_List::merge_sort (List_Node *a_head)
@@ -343,13 +337,13 @@ Key_List::merge_sort (List_Node *a_head)
temp = temp->next;
}
- temp = middle->next;
+ temp = middle->next;
middle->next = 0;
return merge (merge_sort (a_head), merge_sort (temp));
}
}
-/* Returns the frequency of occurrence of elements in the key set. */
+// Returns the frequency of occurrence of elements in the key set.
inline int
Key_List::get_occurrence (List_Node *ptr)
@@ -362,8 +356,8 @@ Key_List::get_occurrence (List_Node *ptr)
return value;
}
-/* Enables the index location of all key set elements that are now
- determined. */
+// Enables the index location of all key set elements that are now
+// determined.
inline void
Key_List::set_determined (List_Node *ptr)
@@ -372,7 +366,7 @@ Key_List::set_determined (List_Node *ptr)
determined[*temp] = 1;
}
-/* Returns TRUE if PTR's key set is already completely determined. */
+// Returns TRUE if PTR's key set is already completely determined.
inline int
Key_List::already_determined (List_Node *ptr)
@@ -385,11 +379,12 @@ Key_List::already_determined (List_Node *ptr)
return is_determined;
}
-/* Reorders the table by first sorting the list so that frequently occuring
- keys appear first, and then the list is reorded so that keys whose values
- are already determined will be placed towards the front of the list. This
- helps prune the search time by handling inevitable collisions early in the
- search process. See Cichelli's paper from Jan 1980 JACM for details.... */
+// Reorders the table by first sorting the list so that frequently
+// occuring keys appear first, and then the list is reorded so that
+// keys whose values are already determined will be placed towards the
+// front of the list. This helps prune the search time by handling
+// inevitable collisions early in the search process. See Cichelli's
+// paper from Jan 1980 JACM for details....
void
Key_List::reorder (void)
@@ -399,7 +394,7 @@ Key_List::reorder (void)
for (ptr = head; ptr; ptr = ptr->next)
ptr->occurrence = get_occurrence (ptr);
- occurrence_sort = !(hash_sort = 0); /* Pretty gross, eh?! */
+ occurrence_sort = !(hash_sort = 0); // Pretty gross, eh?!
for (ptr = head = merge_sort (head); ptr->next; ptr = ptr->next)
{
@@ -428,9 +423,9 @@ Key_List::reorder (void)
}
}
-/* Outputs the maximum and minimum hash values. Since the
- list is already sorted by hash value all we need to do is
- find the final item! */
+// Outputs the maximum and minimum hash values. Since the list is
+// already sorted by hash value all we need to do is find the final
+// item!
void
Key_List::output_min_max ()
@@ -464,25 +459,25 @@ Key_List::output_min_max ()
total_duplicates ? total_duplicates + 1 : 0);
}
-/* Generates the output using a C switch. This trades increased
- search time for decreased table space (potentially *much* less
- space for sparse tables). It the user has specified their own
- struct in the keyword file *and* they enable the POINTER option we
- have extra work to do. The solution here is to maintain a local
- static array of user defined struct's, as with the
- Output_Lookup_Function. Then we use for switch statements to
- perform either a strcmp or strncmp, returning 0 if the str fails to
- match, and otherwise returning a pointer to appropriate index
- location in the local static array. */
+// Generates the output using a C switch. This trades increased
+// search time for decreased table space (potentially *much* less
+// space for sparse tables). It the user has specified their own
+// struct in the keyword file *and* they enable the POINTER option we
+// have extra work to do. The solution here is to maintain a local
+// static array of user defined struct's, as with the
+// Output_Lookup_Function. Then we use for switch statements to
+// perform either a strcmp or strncmp, returning 0 if the str fails to
+// match, and otherwise returning a pointer to appropriate index
+// location in the local static array.
void
Key_List::output_switch (void)
{
char *comp_buffer;
- List_Node *curr = head;
- int pointer_and_type_enabled = option[POINTER] && option[TYPE];
- int total_switches = option.get_total_switches ();
- int switch_size = keyword_list_length () / total_switches;
+ List_Node *curr = head;
+ int pointer_and_type_enabled = option[POINTER] && option[TYPE];
+ int total_switches = option.get_total_switches ();
+ int switch_size = keyword_list_length () / total_switches;
if (pointer_and_type_enabled)
{
@@ -521,7 +516,7 @@ Key_List::output_switch (void)
printf (" {\n");
- /* Properly deal with user's who request multiple switch statements. */
+ // Properly deal with user's who request multiple switch statements.
while (curr)
{
@@ -529,7 +524,7 @@ Key_List::output_switch (void)
int lowest_case_value = curr->hash_value;
int number_of_cases = 0;
- /* Figure out a good cut point to end this switch. */
+ // Figure out a good cut point to end this switch.
for (; temp && ++number_of_cases < switch_size; temp = temp->next)
if (temp->next && temp->hash_value == temp->next->hash_value)
@@ -541,7 +536,8 @@ Key_List::output_switch (void)
else
printf (" {\n");
- /* Output each keyword as part of a switch statement indexed by hash value. */
+ // Output each keyword as part of a switch statement indexed by
+ // hash value.
if (option[POINTER] || option[DUP])
{
@@ -566,7 +562,7 @@ Key_List::output_switch (void)
printf (" /* hash value = %4d, keyword = \"%s\" */", temp->hash_value, temp->key);
putchar ('\n');
- /* Handle `natural links,' i.e., those that occur statically. */
+ // Handle `natural links,' i.e., those that occur statically.
if (temp->link)
{
@@ -581,9 +577,9 @@ Key_List::output_switch (void)
printf (" if (%s) return resword;\n", comp_buffer);
}
}
- /* Handle unresolved duplicate hash values. These are guaranteed
- to be adjacent since we sorted the keyword list by increasing
- hash values. */
+ // Handle unresolved duplicate hash values. These are
+ // guaranteed to be adjacent since we sorted the keyword
+ // list by increasing hash values.
if (temp->next && temp->hash_value == temp->next->hash_value)
{
@@ -658,8 +654,8 @@ Key_List::output_switch (void)
printf (" }\n %s\n}\n", option[OPTIMIZE] ? "" : "}\n return 0;");
}
-/* Prints out a table of keyword lengths, for use with the
- comparison code in generated function ``in_word_set.'' */
+// Prints out a table of keyword lengths, for use with the comparison
+// code in generated function ``in_word_set.''
void
Key_List::output_keylength_table (void)
@@ -690,8 +686,9 @@ Key_List::output_keylength_table (void)
printf ("\n%s%s};\n", indent, indent);
}
}
-/* Prints out the array containing the key words for the Gen_Perf
- hash function. */
+
+// Prints out the array containing the key words for the Gen_Perf hash
+// function.
void
Key_List::output_keyword_table (void)
@@ -705,7 +702,7 @@ Key_List::output_keyword_table (void)
printf ("%sstatic %s%swordlist[] =\n%s%s{\n",
indent, option[CONST] ? "const " : "", struct_tag, indent, indent);
- /* Skip over leading blank entries if there are no duplicates. */
+ // Skip over leading blank entries if there are no duplicates.
if (0 < head->hash_value)
printf (" ");
@@ -714,7 +711,7 @@ Key_List::output_keyword_table (void)
if (0 < head->hash_value && column % 10)
printf ("\n");
- /* Generate an array of reserved words at appropriate locations. */
+ // Generate an array of reserved words at appropriate locations.
for (temp = head ; temp; temp = temp->next, index++)
{
@@ -746,7 +743,7 @@ Key_List::output_keyword_table (void)
printf (" /* hash value = %d, index = %d */", temp->hash_value, temp->index);
putchar ('\n');
- /* Deal with links specially. */
+ // Deal with links specially.
if (temp->link)
for (List_Node *links = temp->link; links; links = links->link)
{
@@ -760,8 +757,8 @@ Key_List::output_keyword_table (void)
printf ("%s%s};\n\n", indent, indent);
}
-/* Generates C code for the hash function that returns the
- proper encoding for each key word. */
+// Generates C code for the hash function that returns the proper
+// encoding for each key word.
void
Key_List::output_hash_function (void)
@@ -769,7 +766,7 @@ Key_List::output_hash_function (void)
const int max_column = 10;
int count = max_hash_value;
- /* Calculate maximum number of digits required for MAX_HASH_VALUE. */
+ // Calculate maximum number of digits required for MAX_HASH_VALUE.
for (field_width = 2; (count /= 10) > 0; field_width++)
;
@@ -799,7 +796,7 @@ Key_List::output_hash_function (void)
Vectors::occurrences[count] ? Vectors::asso_values[count] : max_hash_value + 1);
}
- /* Optimize special case of ``-k 1,$'' */
+ // Optimize special case of ``-k 1,$''
if (option[DEFAULTCHARS])
{
if (option[STRCASECMP])
@@ -815,10 +812,10 @@ Key_List::output_hash_function (void)
option.reset ();
- /* Get first (also highest) key position. */
+ // Get first (also highest) key position.
key_pos = option.get ();
- /* We can perform additional optimizations here. */
+ // We can perform additional optimizations here.
if (!option[ALLCHARS] && key_pos <= min_key_len)
{
printf ("\n };\n return %s", option[NOLENGTH] ? "" : "len + ");
@@ -837,18 +834,18 @@ Key_List::output_hash_function (void)
: "");
}
- /* We've got to use the correct, but brute force, technique. */
+ // We've got to use the correct, but brute force, technique.
else
{
printf ("\n };\n register int hval = %s;\n\n switch (%s)\n {\n default:\n",
option[NOLENGTH] ? "0" : "len", option[NOLENGTH] ? "len" : "hval");
- /* User wants *all* characters considered in hash. */
+ // User wants *all* characters considered in hash.
if (option[ALLCHARS])
{
int i;
- /* Break these options up for speed (gee, is this misplaced efficiency or what?! */
+ // Break these options up for speed (gee, is this misplaced efficiency or what?!
if (option[STRCASECMP])
for (i = max_key_len; i > 0; i--)
@@ -861,7 +858,7 @@ Key_List::output_hash_function (void)
printf (" }\n return hval;\n}\n\n");
}
- else /* do the hard part... */
+ else // do the hard part...
{
count = key_pos + 1;
@@ -887,8 +884,8 @@ Key_List::output_hash_function (void)
}
}
-/* Generates the large, sparse table that maps hash values into
- the smaller, contiguous range of the keyword table. */
+// Generates the large, sparse table that maps hash values in the
+// smaller, contiguous range of the keyword table.
void
Key_List::output_lookup_array (void)
@@ -899,11 +896,11 @@ Key_List::output_lookup_array (void)
struct duplicate_entry
{
- int hash_value; /* Hash value for this particular duplicate set. */
- int index; /* Index into the main keyword storage array. */
- int count; /* Number of consecutive duplicates at this index. */
+ int hash_value; // Hash value for this particular duplicate set.
+ int index; // Index into the main keyword storage array.
+ int count; // Number of consecutive duplicates at this index.
};
-#if LARGE_STACK_ARRAYS
+#if defined (LARGE_STACK_ARRAYS)
duplicate_entry duplicates[total_duplicates];
int lookup_array[max_hash_value + 1];
#else
@@ -913,7 +910,7 @@ Key_List::output_lookup_array (void)
int *lookup_array = (int*)malloc(sizeof(int) * (max_hash_value + 1));
if (duplicates == NULL || lookup_array == NULL)
abort();
-#endif
+#endif /* LARGE_STACK_ARRAYS */
duplicate_entry *dup_ptr = duplicates;
int *lookup_ptr = lookup_array + max_hash_value + 1;
@@ -929,7 +926,7 @@ Key_List::output_lookup_array (void)
if (!temp->link &&
(!temp->next || hash_value != temp->next->hash_value))
continue;
-#if LARGE_STACK_ARRAYS
+#if defined (LARGE_STACK_ARRAYS)
*dup_ptr = (duplicate_entry) { hash_value, temp->index, 1 };
#else
duplicate_entry _dups;
@@ -937,7 +934,7 @@ Key_List::output_lookup_array (void)
_dups.index = temp->index;
_dups.count = 1;
*dup_ptr = _dups;
-#endif
+#endif /* LARGE_STACK_ARRAYS */
for (List_Node *ptr = temp->link; ptr; ptr = ptr->link)
{
@@ -969,7 +966,8 @@ Key_List::output_lookup_array (void)
fprintf (stderr, "dup_ptr[%d]: hash_value = %d, index = %d, count = %d\n",
dup_ptr - duplicates, dup_ptr->hash_value, dup_ptr->index, dup_ptr->count);
- /* Start searching for available space towards the right part of the lookup array. */
+ // Start searching for available space towards the right
+ // part of the lookup array.
int i;
for (i = dup_ptr->hash_value; i < max_hash_value; i++)
if (lookup_array[i] == DEFAULT_VALUE && lookup_array[i + 1] == DEFAULT_VALUE)
@@ -980,7 +978,7 @@ Key_List::output_lookup_array (void)
break;
}
- /* If we didn't find it to the right look to the left instead... */
+ // If we didn't find it to the right look to the left instead...
if (i == max_hash_value)
{
@@ -993,7 +991,7 @@ Key_List::output_lookup_array (void)
break;
}
- /* We are in *big* trouble if this happens! */
+ // We are in *big* trouble if this happens!
assert (i != 0);
}
}
@@ -1014,7 +1012,7 @@ Key_List::output_lookup_array (void)
int count = max;
- /* Calculate maximum number of digits required for MAX_HASH_VALUE. */
+ // Calculate maximum number of digits required for MAX_HASH_VALUE.
for (field_width = 2; (count /= 10) > 0; field_width++)
;
@@ -1034,7 +1032,8 @@ Key_List::output_lookup_array (void)
#endif
}
}
-/* Generates C code to perform the keyword lookup. */
+
+// Generates C code to perform the keyword lookup.
void
Key_List::output_lookup_function (void)
@@ -1118,7 +1117,7 @@ Key_List::output_lookup_function (void)
}
}
-/* Output the table and the functions that map upper case into lower case! */
+// Output the table and the functions that map upper case into lower case!
void
Key_List::output_strcasecmp (void)
@@ -1180,15 +1179,15 @@ Key_List::output_strcasecmp (void)
}
}
-/* Generates the hash function and the key word recognizer function
- based upon the user's Options. */
+// Generates the hash function and the key word recognizer function
+// based upon the user's Options.
void
Key_List::output (void)
{
printf ("%s\n", include_src);
- if (option[TYPE] && !option[NOTYPE]) /* Output type declaration now, reference it later on.... */
+ if (option[TYPE] && !option[NOTYPE]) // Output type declaration now, reference it later on....
printf ("%s;\n", array_type);
output_min_max ();
@@ -1220,7 +1219,7 @@ Key_List::output (void)
output_lookup_array ();
}
- if (option[GNU]) /* Use the inline keyword to remove function overhead. */
+ if (option[GNU]) // Use the inline keyword to remove function overhead.
printf ("#ifdef __GNUC__\ninline\n#endif\n");
printf ("%s%s\n", option[CONST] ? "const " : "", return_type);
@@ -1244,7 +1243,7 @@ Key_List::output (void)
total_keys, min_key_len, max_key_len, min_hash_value,
max_hash_value, max_hash_value - min_hash_value + 1,
total_duplicates ? total_duplicates + 1 : 0);
- /* Use the switch in place of lookup table. */
+ // Use the switch in place of lookup table.
if (option[SWITCH])
{
if (!option[GLOBAL])
@@ -1256,7 +1255,7 @@ Key_List::output (void)
}
output_switch ();
}
- /* Use the lookup table, in place of switch. */
+ // Use the lookup table, in place of switch.
else
{
if (!option[GLOBAL])
@@ -1286,7 +1285,7 @@ Key_List::output (void)
fflush (stdout);
}
-/* Sorts the keys by hash value. */
+// Sorts the keys by hash value.
void
Key_List::sort (void)
@@ -1297,7 +1296,7 @@ Key_List::sort (void)
head = merge_sort (head);
}
-/* Dumps the key list to stderr stream. */
+// Dumps the key list to stderr stream.
void
Key_List::dump ()
@@ -1313,7 +1312,7 @@ Key_List::dump ()
field_width, ptr->char_set, ptr->key);
}
-/* Simple-minded constructor action here... */
+// Simple-minded constructor action here...
Key_List::Key_List (void)
{
@@ -1327,7 +1326,7 @@ Key_List::Key_List (void)
additional_code = 0;
}
-/* Returns the length of entire key list. */
+// Returns the length of entire key list.
int
Key_List::keyword_list_length (void)
@@ -1335,7 +1334,7 @@ Key_List::keyword_list_length (void)
return list_len;
}
-/* Returns length of longest key read. */
+// Returns length of longest key read.
int
Key_List::max_key_length (void)
diff --git a/apps/gperf/src/Key_List.h b/apps/gperf/src/Key_List.h
index bad5e0a2ffa..02eff21ef47 100644
--- a/apps/gperf/src/Key_List.h
+++ b/apps/gperf/src/Key_List.h
@@ -1,51 +1,51 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Data and function member declarations for the keyword list class.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-
-// The key word list is a useful abstraction that keeps track of
-// various pieces of information that enable that fast generation of
-// the Gen_Perf.hash function. A Key_List is a singly-linked list of
-// List_Nodes.
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
-#ifndef key_list_h
-#define key_list_h 1
+#if !defined (KEY_LIST_H)
+#define KEY_LIST_H
#include "Options.h"
#include "List_Node.h"
class Key_List
{
+ // = TITLE
+ // Data and function member declarations for the keyword list class.
+ //
+ // = DESCRIPTION
+ // The key word list is a useful abstraction that keeps track of
+ // various pieces of information that enable that fast generation of
+ // the Gen_Perf.hash function. A Key_List is a singly-linked list
+ // of List_Nodes.
public:
Key_List (void);
~Key_List (void);
- int keyword_list_length (void);
- int max_key_length (void);
- void reorder (void);
- void sort (void);
- void read_keys (void);
- void output (void);
+ int keyword_list_length (void);
+ int max_key_length (void);
+ void reorder (void);
+ void sort (void);
+ void read_keys (void);
+ void output (void);
List_Node *head;
// Points to the head of the linked list.
@@ -55,24 +55,27 @@ public:
private:
static int get_occurrence (List_Node *ptr);
- static int strcspn (const char *s, const char *reject);
static int already_determined (List_Node *ptr);
static void set_determined (List_Node *ptr);
- void output_min_max (void);
- void output_switch (void);
- void output_keyword_table (void);
- void output_keylength_table (void);
- void output_hash_function (void);
- void output_lookup_function (void);
- void output_lookup_array (void);
- void output_strcasecmp (void);
- void set_output_types (void);
- void dump (void);
- char *get_array_type (void);
- char *save_include_src (void);
- char *get_special_input (char delimiter);
- List_Node *merge (List_Node *list1, List_Node *list2);
- List_Node *merge_sort (List_Node *head);
+
+ // @@ All of the following methods should be factored out and
+ // replaced by the use of the Strategy/Bridge pattern so that we can
+ // easily add new languages.
+ void output_min_max (void);
+ void output_switch (void);
+ void output_keyword_table (void);
+ void output_keylength_table (void);
+ void output_hash_function (void);
+ void output_lookup_function (void);
+ void output_lookup_array (void);
+ void output_strcasecmp (void);
+ void set_output_types (void);
+ void dump (void);
+ char *get_array_type (void);
+ char *save_include_src (void);
+ char *get_special_input (char delimiter);
+ List_Node *merge (List_Node *list1, List_Node *list2);
+ List_Node *merge_sort (List_Node *head);
char *array_type;
// Pointer to the type for word list.
@@ -113,4 +116,5 @@ private:
int total_keys;
// Total number of keys, counting duplicates.
};
-#endif
+
+#endif /* KEY_LIST_H */
diff --git a/apps/gperf/src/List_Node.cpp b/apps/gperf/src/List_Node.cpp
index 59643b97b17..245a9dec6eb 100644
--- a/apps/gperf/src/List_Node.cpp
+++ b/apps/gperf/src/List_Node.cpp
@@ -1,34 +1,34 @@
-/* Creates and initializes a new list node.
// $Id$
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "Vectors.h"
#include "List_Node.h"
-/* Defined as a macro in string.h on some systems, which causes
- conflicts. */
+// Defined as a macro in string.h on some systems, which causes
+// conflicts.
#undef index
-/* Sorts the key set alphabetically to speed up subsequent operations.
- Uses insertion sort since the set is probably quite small. */
+// Sorts the key set alphabetically to speed up subsequent operation
+// Uses insertion sort since the set is probably quite small.
inline void
List_Node::set_sort (char *base, int len)
@@ -39,7 +39,9 @@ List_Node::set_sort (char *base, int len)
{
char curr, tmp;
- for (curr = i + 1, tmp = base[curr]; curr > 0 && tmp < base[curr-1]; curr--)
+ for (curr = i + 1, tmp = base[curr];
+ curr > 0 && tmp < base[curr-1];
+ curr--)
base[curr] = base[curr - 1];
base[curr] = tmp;
@@ -47,18 +49,18 @@ List_Node::set_sort (char *base, int len)
}
}
-/* Initializes a List_Node. This requires obtaining memory for the
- CHAR_SET initializing them using the information stored in the
- KEY_POSITIONS array in Options, and checking for simple errors.
- It's important to note that KEY and REST are both pointers to the
- different offsets into the same block of dynamic memory pointed to
- by parameter K. The data member REST is used to store any
- additional fields of the input file (it is set to the "" string if
- Option[TYPE] is not enabled). This is useful if the user wishes to
- incorporate a lookup structure, rather than just an array of keys.
- Finally, KEY_NUMBER contains a count of the total number of keys
- seen so far. This is used to initialize the INDEX field to some
- useful value. */
+// Initializes a List_Node. This requires obtaining memory for the
+// CHAR_SET initializing them using the information stored in the
+// KEY_POSITIONS array in Options, and checking for simple errors.
+// It's important to note that KEY and REST are both pointers to the
+// different offsets into the same block of dynamic memory pointed to
+// by parameter K. The data member REST is used to store any
+// additional fields of the input file (it is set to the "" string if
+// Option[TYPE] is not enabled). This is useful if the user wishes to
+// incorporate a lookup structure, rather than just an array of keys.
+// Finally, KEY_NUMBER contains a count of the total number of keys
+// seen so far. This is used to initialize the INDEX field to some
+// useful value.
List_Node::List_Node (char *k, int len)
: key (k),
@@ -70,41 +72,44 @@ List_Node::List_Node (char *k, int len)
{
char *ptr = new char[(option[ALLCHARS] ? len : option.get_max_keysig_size ()) + 1];
char_set = ptr;
- k[len] = '\0'; /* Null terminate KEY to separate it from REST. */
+ k[len] = '\0'; // Null terminate KEY to separate it from REST.
- /* Lower case if STRCASECMP option is enabled. */
+ // Lower case if STRCASECMP option is enabled.
if (option[STRCASECMP])
for (char *p = k; *p; p++)
if (isupper (*p))
*p = tolower (*p);
- if (option[ALLCHARS]) /* Use all the character position in the KEY. */
+ if (option[ALLCHARS]) // Use all the character position in the KEY.
for (; *k; k++, ptr++)
++Vectors::occurrences[*ptr = *k];
- else /* Only use those character positions specified by the user. */
+ else // Only use those character positions specified by the user.
{
int i;
- /* Iterate thru the list of key_positions, initializing occurrences table
- and char_set (via char * pointer ptr). */
+ // Iterate thru the list of key_positions, initializing
+ // occurrences table and char_set (via char * pointer ptr).
for (option.reset (); (i = option.get ()) != EOS; )
{
- if (i == WORD_END) /* Special notation for last KEY position, i.e. '$'. */
+ if (i == WORD_END) // Special notation for last KEY position, i.e. '$'.
*ptr = key[len - 1];
- else if (i <= len) /* Within range of KEY length, so we'll keep it. */
+ else if (i <= len) // Within range of KEY length, so we'll keep it.
*ptr = key[i - 1];
- else /* Out of range of KEY length, so we'll just skip it. */
+ else // Out of range of KEY length, so we'll just skip it.
continue;
++Vectors::occurrences[*ptr++];
}
- /* Didn't get any hits and user doesn't want to consider the
- keylength, so there are essentially no usable hash positions! */
+ // Didn't get any hits and user doesn't want to consider the
+ // keylength, so there are essentially no usable hash positions!
if (ptr == char_set && option[NOLENGTH])
- ACE_ERROR ((LM_ERROR, "Can't hash keyword %s with chosen key positions.\n%a", key, 1));
+ ACE_ERROR ((LM_ERROR,
+ "Can't hash keyword %s with chosen key positions.\n%a",
+ key,
+ 1));
}
- *ptr = '\0'; /* Terminate this bastard.... */
- /* Sort the KEY_SET items alphabetically. */
+ *ptr = '\0'; // Terminate this bastard....
+ // Sort the KEY_SET items alphabetically.
set_sort (char_set, ptr - char_set);
}
diff --git a/apps/gperf/src/List_Node.h b/apps/gperf/src/List_Node.h
index 6b3e86ce694..58b932e0739 100644
--- a/apps/gperf/src/List_Node.h
+++ b/apps/gperf/src/List_Node.h
@@ -1,36 +1,37 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Data and function members for defining values and operations of a list node.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
-#ifndef list_node_h
-#define list_node_h 1
+#if !defined (LIST_NODE_H)
+#define LIST_NODE_H
#include "Options.h"
-struct List_Node
+class List_Node
{
+ // = TITLE
+ // Data and function members for defining values and operations of
+ // a list node.
+public:
List_Node (char *key, int len);
static void set_sort (char *base, int len);
@@ -62,4 +63,4 @@ struct List_Node
// Position of this node relative to other nodes.
};
-#endif
+#endif /* LIST_NODE_H */
diff --git a/apps/gperf/src/Options.cpp b/apps/gperf/src/Options.cpp
index 1aa819503e7..1642d2a6fb0 100644
--- a/apps/gperf/src/Options.cpp
+++ b/apps/gperf/src/Options.cpp
@@ -1,51 +1,53 @@
-/* Handles parsing the Options provided to the user.
// $Id$
- Copyright (C) 1989 Free Software Foundation, Inc.
+// Handles parsing the Options provided to the user.
+
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "ace/Get_Opt.h"
#include "Options.h"
#include "Iterator.h"
-/* Global option coordinator for the entire program. */
+// Global option coordinator for the entire program.
Options option;
-/* Current program version. */
+// Current program version.
extern char *version_string;
-/* Size to jump on a collision. */
+// Size to jump on a collision.
static const int DEFAULT_JUMP_VALUE = 5;
-/* Default name for generated lookup function. */
+// Default name for generated lookup function.
static const char *const DEFAULT_NAME = "in_word_set";
-/* Default name for the key component. */
+// Default name for the key component.
static const char *const DEFAULT_KEY = "name";
-/* Default name for the generated class. */
+// Default name for the generated class.
static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
-/* Default name for generated hash function. */
+// Default name for generated hash function.
static const char *const DEFAULT_HASH_NAME = "hash";
-/* Default delimiters that separate keywords from their attributes. */
+// Default delimiters that separate keywords from their attributes.
static const char *const DEFAULT_DELIMITERS = ",\n";
int Options::option_word;
@@ -65,16 +67,17 @@ const char *Options::hash_name;
const char *Options::delimiters;
char Options::key_positions[MAX_KEY_POS];
-/* Prints program usage to standard error stream. */
+// Prints program usage to standard error stream.
-inline void
+void
Options::usage (void)
{
- ACE_ERROR ((LM_ERROR, "Usage: %n [-acCdDef[num]gGhH<hashname>i<init>Ijk<keys>K<keyname>lL<language>nN<function name>oOprs<size>S<switches>tTvZ<class name>].\n"
- "(type %n -h for help)\n"));
+ ACE_ERROR ((LM_ERROR,
+ "Usage: %n [-acCdDef[num]gGhH<hashname>i<init>Ijk<keys>K<keyname>lL<language>nN<function name>oOprs<size>S<switches>tTvZ<class name>].\n"
+ "(type %n -h for help)\n"));
}
-/* Output command-line Options. */
+// Output command-line Options.
void
Options::print_options (void)
@@ -89,12 +92,12 @@ Options::print_options (void)
printf (" */");
}
-/* Sorts the key positions *IN REVERSE ORDER!!*
- This makes further routines more efficient. Especially when generating code.
- Uses a simple Insertion Sort since the set is probably ordered.
- Returns 1 if there are no duplicates, 0 otherwise. */
+// Sorts the key positions *IN REVERSE ORDER!!* This makes further
+// routines more efficient. Especially when generating code. Uses a
+// simple Insertion Sort since the set is probably ordered. Returns 1
+// if there are no duplicates, 0 otherwise.
-inline int
+int
Options::key_sort (char *base, int len)
{
int i, j;
@@ -103,8 +106,10 @@ Options::key_sort (char *base, int len)
{
int curr, tmp;
- for (curr = i + 1,tmp = base[curr]; curr > 0 && tmp >= base[curr - 1]; curr--)
- if ((base[curr] = base[curr - 1]) == tmp) /* oh no, a duplicate!!! */
+ for (curr = i + 1, tmp = base[curr];
+ curr > 0 && tmp >= base[curr - 1];
+ curr--)
+ if ((base[curr] = base[curr - 1]) == tmp) // oh no, a duplicate!!!
return 0;
base[curr] = tmp;
@@ -113,86 +118,85 @@ Options::key_sort (char *base, int len)
return 1;
}
-/* Sets the default Options. */
+// Sets the default Options.
Options::Options (void)
{
- key_positions[0] = WORD_START;
- key_positions[1] = WORD_END;
- key_positions[2] = EOS;
- total_keysig_size = 2;
- delimiters = DEFAULT_DELIMITERS;
- jump = DEFAULT_JUMP_VALUE;
- option_word = DEFAULTCHARS | C;
- function_name = DEFAULT_NAME;
- key_name = DEFAULT_KEY;
- hash_name = DEFAULT_HASH_NAME;
- class_name = DEFAULT_CLASS_NAME;
- total_switches = size = 1;
- initial_asso_value = iterations = 0;
+ key_positions[0] = WORD_START;
+ key_positions[1] = WORD_END;
+ key_positions[2] = EOS;
+ total_keysig_size = 2;
+ delimiters = DEFAULT_DELIMITERS;
+ jump = DEFAULT_JUMP_VALUE;
+ option_word = DEFAULTCHARS | C;
+ function_name = DEFAULT_NAME;
+ key_name = DEFAULT_KEY;
+ hash_name = DEFAULT_HASH_NAME;
+ class_name = DEFAULT_CLASS_NAME;
+ total_switches = size = 1;
+ initial_asso_value = iterations = 0;
}
-/* Dumps option status when debug is set. */
+// Dumps option status when debug is set.
Options::~Options (void)
{
- if (option_word & DEBUG)
+ if (ACE_BIT_ENABLED (option_word, DEBUG))
{
char *ptr;
- fprintf (stderr, "\ndumping Options:\nDEBUG is.......: %s\nORDER is.......: %s"
- "\nANSI is........: %s\nTYPE is........: %s\nGNU is.........: %s"
- "\nRANDOM is......: %s\nDEFAULTCHARS is: %s\nSWITCH is......: %s"
- "\nPOINTER is.....: %s\nNOLENGTH is....: %s\nLENTABLE is....: %s"
- "\nDUP is.........: %s\nFAST is........: %s\nCOMP is.....: %s"
- "\nNOTYPE is......: %s\nGLOBAL is......: %s\nCONST is....: %s"
- "\nCPLUSPLUS is...: %s\nC is...........: %s\nENUM is.....: %s"
- "\nSTRCASECMP is...: %s\nOPTIMIZE is...........: %s"
- "\niterations = %d\nlookup function name = %s\nhash function name = %s"
- "\nkey name = %s\njump value = %d\nmax associcated value = %d"
- "\ninitial associated value = %d\ndelimiters = %s\nnumber of switch statements = %d\n",
- option_word & DEBUG ? "enabled" : "disabled",
- option_word & ORDER ? "enabled" : "disabled",
- option_word & ANSI ? "enabled" : "disabled",
- option_word & TYPE ? "enabled" : "disabled",
- option_word & GNU ? "enabled" : "disabled",
- option_word & RANDOM ? "enabled" : "disabled",
- option_word & DEFAULTCHARS ? "enabled" : "disabled",
- option_word & SWITCH ? "enabled" : "disabled",
- option_word & POINTER ? "enabled" : "disabled",
- option_word & NOLENGTH ? "enabled" : "disabled",
- option_word & LENTABLE ? "enabled" : "disabled",
- option_word & DUP ? "enabled" : "disabled",
- option_word & FAST ? "enabled" : "disabled",
- option_word & COMP ? "enabled" : "disabled",
- option_word & NOTYPE ? "enabled" : "disabled",
- option_word & GLOBAL ? "enabled" : "disabled",
- option_word & CONST ? "enabled" : "disabled",
- option_word & CPLUSPLUS ? "enabled" : "disabled",
- option_word & C ? "enabled" : "disabled",
- option_word & ENUM ? "enabled" : "disabled",
- option_word & STRCASECMP ? "enabled" : "disabled",
- option_word & OPTIMIZE ? "enabled" : "disabled",
- iterations, function_name, hash_name, key_name, jump, size - 1,
- initial_asso_value, delimiters, total_switches);
- if (option_word & ALLCHARS)
- fprintf (stderr, "all characters are used in the hash function\n");
-
- fprintf (stderr, "maximum keysig size = %d\nkey positions are: \n",
+ ACE_OS::fprintf (stderr, "\ndumping Options:\nDEBUG is.......: %s\nORDER is.......: %s"
+ "\nANSI is........: %s\nTYPE is........: %s\nGNU is.........: %s"
+ "\nRANDOM is......: %s\nDEFAULTCHARS is: %s\nSWITCH is......: %s"
+ "\nPOINTER is.....: %s\nNOLENGTH is....: %s\nLENTABLE is....: %s"
+ "\nDUP is.........: %s\nFAST is........: %s\nCOMP is.....: %s"
+ "\nNOTYPE is......: %s\nGLOBAL is......: %s\nCONST is....: %s"
+ "\nCPLUSPLUS is...: %s\nC is...........: %s\nENUM is.....: %s"
+ "\nSTRCASECMP is...: %s\nOPTIMIZE is...........: %s"
+ "\niterations = %d\nlookup function name = %s\nhash function name = %s"
+ "\nkey name = %s\njump value = %d\nmax associcated value = %d"
+ "\ninitial associated value = %d\ndelimiters = %s\nnumber of switch statements = %d\n",
+ ACE_BIT_ENABLED (option_word, DEBUG) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, ORDER) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, ANSI) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, TYPE) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, GNU) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, RANDOM) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, DEFAULTCHARS) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, SWITCH) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, POINTER) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, NOLENGTH) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, LENTABLE) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, DUP) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, FAST) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, COMP) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, NOTYPE) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, GLOBAL) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, CONST) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, CPLUSPLUS) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, C) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, ENUM) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, STRCASECMP) ? "enabled" : "disabled",
+ ACE_BIT_ENABLED (option_word, OPTIMIZE) ? "enabled" : "disabled",
+ iterations, function_name, hash_name, key_name, jump, size - 1,
+ initial_asso_value, delimiters, total_switches);
+ if (ACE_BIT_ENABLED (option_word, ALLCHARS))
+ ACE_OS::fprintf (stderr, "all characters are used in the hash function\n");
+
+ ACE_OS::fprintf (stderr, "maximum keysig size = %d\nkey positions are: \n",
total_keysig_size);
for (ptr = key_positions; *ptr != EOS; ptr++)
if (*ptr == WORD_END)
- fprintf (stderr, "$\n");
+ ACE_OS::fprintf (stderr, "$\n");
else
- fprintf (stderr, "%d\n", *ptr);
+ ACE_OS::fprintf (stderr, "%d\n", *ptr);
- fprintf (stderr, "finished dumping Options\n");
+ ACE_OS::fprintf (stderr, "finished dumping Options\n");
}
}
-
-/* Parses the command line Options and sets appropriate flags in option_word. */
+// Parses the command line Options and sets appropriate flags in option_word.
void
Options::operator() (int argc, char *argv[])
@@ -209,46 +213,46 @@ Options::operator() (int argc, char *argv[])
{
switch (option_char)
{
- case 'a': /* Generated coded uses the ANSI prototype format. */
+ case 'a': // Generated coded uses the ANSI prototype format.
{
- option_word |= ANSI;
+ ACE_SET_BITS (option_word, ANSI);
break;
}
- case 'c': /* Generate strncmp rather than strcmp. */
+ case 'c': // Generate strncmp rather than strcmp.
{
- option_word |= COMP;
+ ACE_SET_BITS (option_word, COMP);
break;
}
- case 'C': /* Make the generated tables readonly (const). */
+ case 'C': // Make the generated tables readonly (const).
{
- option_word |= CONST;
+ ACE_SET_BITS (option_word, CONST);
break;
}
- case 'd': /* Enable debugging option. */
+ case 'd': // Enable debugging option.
{
- option_word |= DEBUG;
+ ACE_SET_BITS (option_word, DEBUG);
ACE_ERROR ((LM_ERROR, "Starting program %n, version %s, with debuggin on.\n",
version_string));
break;
}
- case 'D': /* Enable duplicate option. */
+ case 'D': // Enable duplicate option.
{
- option_word |= DUP;
+ ACE_SET_BITS (option_word, DUP);
break;
}
- case 'e': /* Allows user to provide keyword/attribute separator */
+ case 'e': // Allows user to provide keyword/attribute separator
{
option.delimiters = getopt.optarg;
break;
}
case 'E':
{
- option_word |= ENUM;
+ ACE_SET_BITS (option_word, ENUM);
break;
}
- case 'f': /* Generate the hash table ``fast.'' */
+ case 'f': // Generate the hash table ``fast.''
{
- option_word |= FAST;
+ ACE_SET_BITS (option_word, FAST);
if ((iterations = atoi (getopt.optarg)) < 0)
{
ACE_ERROR ((LM_ERROR, "iterations value must not be negative, assuming 0\n"));
@@ -256,102 +260,106 @@ Options::operator() (int argc, char *argv[])
}
break;
}
- case 'g': /* Use the ``inline'' keyword for generated sub-routines. */
+ case 'g': // Use the ``inline'' keyword for generated sub-routines.
{
- option_word |= GNU;
+ ACE_SET_BITS (option_word, GNU);
break;
}
- case 'G': /* Make the keyword table a global variable. */
+ case 'G': // Make the keyword table a global variable.
{
- option_word |= GLOBAL;
+ ACE_SET_BITS (option_word, GLOBAL);
break;
}
- case 'h': /* Displays a list of helpful Options to the user. */
+ case 'h': // Displays a list of helpful Options to the user.
{
- ACE_ERROR ((LM_ERROR,
- "-a\tGenerate ANSI standard C output code, i.e., function prototypes.\n"
- "-c\tGenerate comparison code using strncmp rather than strcmp.\n"
- "-C\tMake the contents of generated lookup tables constant, i.e., readonly.\n"
- "-d\tEnables the debugging option (produces verbose output to the standard error).\n"
- "-D\tHandle keywords that hash to duplicate values. This is useful\n"
- "\tfor certain highly redundant keyword sets. It enables the -S option.\n"
- "-e\tAllow user to provide a string containing delimiters used to separate\n"
- "\tkeywords from their attributes. Default is \",\\n\"\n"
- "-E\tDefine constant values using an enum local to the lookup function\n"
- "\trather than with defines\n"
- "-f\tGenerate the gen-perf.hash function ``fast.'' This decreases GPERF's\n"
- "\trunning time at the cost of minimizing generated table-size.\n"
- "\tThe numeric argument represents the number of times to iterate when\n"
- "\tresolving a collision. `0' means ``iterate by the number of keywords.''\n"
- "-g\tAssume a GNU compiler, e.g., g++ or gcc. This makes all generated\n"
- "\troutines use the ``inline'' keyword to remove cost of function calls.\n"
- "-G\tGenerate the static table of keywords as a static global variable,\n"
- "\trather than hiding it inside of the lookup function (which is the\n"
- "\tdefault behavior).\n"
- "-h\tPrints this mesage.\n"
- "-H\tAllow user to specify name of generated hash function. Default\n"
- "\tis `hash'.\n"
- "-i\tProvide an initial value for the associate values array. Default is 0.\n"
- "-I\tGenerate comparison code using case insensitive string comparison, e.g.,\n"
- "\tstrncasecmp or strcasecmp.\n"
- "\tSetting this value larger helps inflate the size of the final table.\n"
- "-j\tAffects the ``jump value,'' i.e., how far to advance the associated\n"
- "\tcharacter value upon collisions. Must be an odd number, default is %d.\n"
- "-k\tAllows selection of the key positions used in the hash function.\n"
- "\tThe allowable choices range between 1-%d, inclusive. The positions\n"
- "\tare separated by commas, ranges may be used, and key positions may\n"
- "\toccur in any order. Also, the meta-character '*' causes the generated\n"
- "\thash function to consider ALL key positions, and $ indicates the\n"
- "\t``final character'' of a key, e.g., $,1,2,4,6-10.\n"
- "-K\tAllow use to select name of the keyword component in the keyword structure.\n"
- "-l\tCompare key lengths before trying a string comparison. This helps\n"
- "\tcut down on the number of string comparisons made during the lookup.\n"
- "-L\tGenerates code in the language specified by the option's argument. Languages\n"
- "\thandled are currently C++ and C. The default is C.\n"
- "-n\tDo not include the length of the keyword when computing the hash function\n"
- "-N\tAllow user to specify name of generated lookup function. Default\n"
- "\tname is `in_word_set.'\n"
- "-o\tReorders input keys by frequency of occurrence of the key sets.\n"
- "\tThis should decrease the search time dramatically.\n"
- "-O\tOptimize the generated lookup function by assuming that all input keywords \n"
- "\tare members of the keyset from the keyfile.\n"
- "-p\tChanges the return value of the generated function ``in_word_set''\n"
- "\tfrom its default boolean value (i.e., 0 or 1), to type ``pointer\n"
- "\tto wordlist array'' This is most useful when the -t option, allowing\n"
- "\tuser-defined structs, is used.\n"
- "-r\tUtilizes randomness to initialize the associated values table.\n"
- "-s\tAffects the size of the generated hash table. The numeric argument\n"
- "\tfor this option indicates ``how many times larger or smaller'' the associated\n"
- "\tvalue range should be, in relationship to the number of keys, e.g. a value of 3\n"
- "\tmeans ``allow the maximum associated value to be about 3 times larger than the\n"
- "\tnumber of input keys.'' Conversely, a value of -3 means ``make the maximum\n"
- "\tassociated value about 3 times smaller than the number of input keys.\n"
- "\tA larger table should decrease the time required for an unsuccessful search,\n"
- "\tat the expense of extra table space. Default value is 1.\n"
- "-S\tCauses the generated C code to use a switch statement scheme, rather\n"
- "\tthan an array lookup table. This can lead to a reduction in both\n"
- "\ttime and space requirements for some keyfiles. The argument to\n"
- "\tthis option determines how many switch statements are generated.\n"
- "\tA value of 1 generates 1 switch containing all the elements, a value of 2\n"
- "\tgenerates 2 tables with 1/2 the elements in each table, etc. This\n"
- "\tis useful since many C compilers cannot correctly generate code for\n"
- "\tlarge switch statements.\n"
- "-t\tAllows the user to include a structured type declaration for \n"
- "\tgenerated code. Any text before %%%% is consider part of the type\n"
- "\tdeclaration. Key words and additional fields may follow this, one\n"
- "\tgroup of fields per line.\n"
- "-T\tPrevents the transfer of the type declaration to the output file.\n"
- "\tUse this option if the type is already defined elsewhere.\n"
- "-v\tPrints out the current version number\n"
- "-Z\tAllow user to specify name of generated C++ class. Default\n"
- "\tname is `Perfect_Hash.'\n%e%a", DEFAULT_JUMP_VALUE, (MAX_KEY_POS - 1), usage, 1));
+ ACE_OS::fprintf (stderr,
+ "-a\tGenerate ANSI standard C output code, i.e., function prototypes.\n"
+ "-c\tGenerate comparison code using strncmp rather than strcmp.\n"
+ "-C\tMake the contents of generated lookup tables constant, i.e., readonly.\n"
+ "-d\tEnables the debugging option (produces verbose output to the standard error).\n"
+ "-D\tHandle keywords that hash to duplicate values. This is useful\n"
+ "\tfor certain highly redundant keyword sets. It enables the -S option.\n"
+ "-e\tAllow user to provide a string containing delimiters used to separate\n"
+ "\tkeywords from their attributes. Default is \",\\n\"\n"
+ "-E\tDefine constant values using an enum local to the lookup function\n"
+ "\trather than with defines\n"
+ "-f\tGenerate the gen-perf.hash function ``fast.'' This decreases GPERF's\n"
+ "\trunning time at the cost of minimizing generated table-size.\n"
+ "\tThe numeric argument represents the number of times to iterate when\n"
+ "\tresolving a collision. `0' means ``iterate by the number of keywords.''\n"
+ "-g\tAssume a GNU compiler, e.g., g++ or gcc. This makes all generated\n"
+ "\troutines use the ``inline'' keyword to remove cost of function calls.\n"
+ "-G\tGenerate the static table of keywords as a static global variable,\n"
+ "\trather than hiding it inside of the lookup function (which is the\n"
+ "\tdefault behavior).\n"
+ "-h\tPrints this mesage.\n"
+ "-H\tAllow user to specify name of generated hash function. Default\n"
+ "\tis `hash'.\n"
+ "-i\tProvide an initial value for the associate values array. Default is 0.\n"
+ "-I\tGenerate comparison code using case insensitive string comparison, e.g.,\n"
+ "\tstrncasecmp or strcasecmp.\n"
+ "\tSetting this value larger helps inflate the size of the final table.\n"
+ "-j\tAffects the ``jump value,'' i.e., how far to advance the associated\n"
+ "\tcharacter value upon collisions. Must be an odd number, default is %d.\n"
+ "-k\tAllows selection of the key positions used in the hash function.\n"
+ "\tThe allowable choices range between 1-%d, inclusive. The positions\n"
+ "\tare separated by commas, ranges may be used, and key positions may\n"
+ "\toccur in any order. Also, the meta-character '*' causes the generated\n"
+ "\thash function to consider ALL key positions, and $ indicates the\n"
+ "\t``final character'' of a key, e.g., $,1,2,4,6-10.\n"
+ "-K\tAllow use to select name of the keyword component in the keyword structure.\n"
+ "-l\tCompare key lengths before trying a string comparison. This helps\n"
+ "\tcut down on the number of string comparisons made during the lookup.\n"
+ "-L\tGenerates code in the language specified by the option's argument. Languages\n"
+ "\thandled are currently C++ and C. The default is C.\n"
+ "-n\tDo not include the length of the keyword when computing the hash function\n"
+ "-N\tAllow user to specify name of generated lookup function. Default\n"
+ "\tname is `in_word_set.'\n"
+ "-o\tReorders input keys by frequency of occurrence of the key sets.\n"
+ "\tThis should decrease the search time dramatically.\n"
+ "-O\tOptimize the generated lookup function by assuming that all input keywords \n"
+ "\tare members of the keyset from the keyfile.\n"
+ "-p\tChanges the return value of the generated function ``in_word_set''\n"
+ "\tfrom its default boolean value (i.e., 0 or 1), to type ``pointer\n"
+ "\tto wordlist array'' This is most useful when the -t option, allowing\n"
+ "\tuser-defined structs, is used.\n"
+ "-r\tUtilizes randomness to initialize the associated values table.\n"
+ "-s\tAffects the size of the generated hash table. The numeric argument\n"
+ "\tfor this option indicates ``how many times larger or smaller'' the associated\n"
+ "\tvalue range should be, in relationship to the number of keys, e.g. a value of 3\n"
+ "\tmeans ``allow the maximum associated value to be about 3 times larger than the\n"
+ "\tnumber of input keys.'' Conversely, a value of -3 means ``make the maximum\n"
+ "\tassociated value about 3 times smaller than the number of input keys.\n"
+ "\tA larger table should decrease the time required for an unsuccessful search,\n"
+ "\tat the expense of extra table space. Default value is 1.\n"
+ "-S\tCauses the generated C code to use a switch statement scheme, rather\n"
+ "\tthan an array lookup table. This can lead to a reduction in both\n"
+ "\ttime and space requirements for some keyfiles. The argument to\n"
+ "\tthis option determines how many switch statements are generated.\n"
+ "\tA value of 1 generates 1 switch containing all the elements, a value of 2\n"
+ "\tgenerates 2 tables with 1/2 the elements in each table, etc. This\n"
+ "\tis useful since many C compilers cannot correctly generate code for\n"
+ "\tlarge switch statements.\n"
+ "-t\tAllows the user to include a structured type declaration for \n"
+ "\tgenerated code. Any text before %%%% is consider part of the type\n"
+ "\tdeclaration. Key words and additional fields may follow this, one\n"
+ "\tgroup of fields per line.\n"
+ "-T\tPrevents the transfer of the type declaration to the output file.\n"
+ "\tUse this option if the type is already defined elsewhere.\n"
+ "-v\tPrints out the current version number\n"
+ "-Z\tAllow user to specify name of generated C++ class. Default\n"
+ "\tname is `Perfect_Hash.'\n%e",
+ DEFAULT_JUMP_VALUE,
+ (MAX_KEY_POS - 1),
+ usage);
+ ACE_OS::exit (1);
}
- case 'H': /* Sets the name for the hash function */
+ case 'H': // Sets the name for the hash function.
{
hash_name = getopt.optarg;
break;
}
- case 'i': /* Sets the initial value for the associated values array. */
+ case 'i': // Sets the initial value for the associated values array.
{
if ((initial_asso_value = atoi (getopt.optarg)) < 0)
ACE_ERROR ((LM_ERROR, "Initial value %d should be non-zero, ignoring and continuing.\n", initial_asso_value));
@@ -361,10 +369,10 @@ Options::operator() (int argc, char *argv[])
}
case 'I':
{
- option_word |= STRCASECMP;
+ ACE_SET_BITS (option_word, STRCASECMP);
break;
}
- case 'j': /* Sets the jump value, must be odd for later algorithms. */
+ case 'j': // Sets the jump value, must be odd for later algorithms.
{
if ((jump = atoi (getopt.optarg)) < 0)
ACE_ERROR ((LM_ERROR, "Jump value %d must be a positive number.\n%e%a", jump, usage, 1));
@@ -372,13 +380,13 @@ Options::operator() (int argc, char *argv[])
ACE_ERROR ((LM_ERROR, "Jump value %d should be odd, adding 1 and continuing...\n", jump++));
break;
}
- case 'k': /* Sets key positions used for hash function. */
+ case 'k': // Sets key positions used for hash function.
{
const int BAD_VALUE = -1;
int value;
Iterator expand (getopt.optarg, 1, MAX_KEY_POS - 1, WORD_END, BAD_VALUE, EOS);
- if (*getopt.optarg == '*') /* Use all the characters for hashing!!!! */
+ if (*getopt.optarg == '*') // Use all the characters for hashing!!!!
option_word = (option_word & ~DEFAULTCHARS) | ALLCHARS;
else
{
@@ -404,88 +412,88 @@ Options::operator() (int argc, char *argv[])
}
break;
}
- case 'K': /* Make this the keyname for the keyword component field. */
+ case 'K': // Make this the keyname for the keyword component field.
{
key_name = getopt.optarg;
break;
}
- case 'l': /* Create length table to avoid extra string compares. */
+ case 'l': // Create length table to avoid extra string compares.
{
- option_word |= LENTABLE;
+ ACE_SET_BITS (option_word, LENTABLE);
break;
}
- case 'L': /* Deal with different generated languages. */
+ case 'L': // Deal with different generated languages.
{
option_word &= ~C;
if (!strcmp (getopt.optarg, "C++"))
- option_word |= (CPLUSPLUS | ANSI);
+ ACE_SET_BITS (option_word, (CPLUSPLUS | ANSI));
else if (!strcmp (getopt.optarg, "C"))
- option_word |= C;
+ ACE_SET_BITS (option_word, C);
else
{
ACE_ERROR ((LM_ERROR, "unsupported language option %s, defaulting to C\n", getopt.optarg));
- option_word |= C;
+ ACE_SET_BITS (option_word, C);
}
break;
}
- case 'n': /* Don't include the length when computing hash function. */
+ case 'n': // Don't include the length when computing hash function.
{
- option_word |= NOLENGTH;
+ ACE_SET_BITS (option_word, NOLENGTH);
break;
}
- case 'N': /* Make generated lookup function name be optarg */
+ case 'N': // Make generated lookup function name be optarg
{
function_name = getopt.optarg;
break;
}
- case 'o': /* Order input by frequency of key set occurrence. */
+ case 'o': // Order input by frequency of key set occurrence.
{
- option_word |= ORDER;
+ ACE_SET_BITS (option_word, ORDER);
break;
}
case 'O':
{
- option_word |= OPTIMIZE;
+ ACE_SET_BITS (option_word, OPTIMIZE);
break;
}
- case 'p': /* Generated lookup function now a pointer instead of int. */
+ case 'p': // Generated lookup function now a pointer instead of int.
{
- option_word |= POINTER;
+ ACE_SET_BITS (option_word, POINTER);
break;
}
- case 'r': /* Utilize randomness to initialize the associated values table. */
+ case 'r': // Utilize randomness to initialize the associated values table.
{
- option_word |= RANDOM;
+ ACE_SET_BITS (option_word, RANDOM);
if (option.initial_asso_value != 0)
ACE_ERROR ((LM_ERROR, "warning, -r option superceeds -i, disabling -i option and continuing\n"));
break;
}
- case 's': /* Range of associated values, determines size of final table. */
+ case 's': // Range of associated values, determines size of final table.
{
if (abs (size = atoi (getopt.optarg)) > 50)
ACE_ERROR ((LM_ERROR, "%d is excessive, did you really mean this?! (type %n -h for help)\n", size));
break;
}
- case 'S': /* Generate switch statement output, rather than lookup table. */
+ case 'S': // Generate switch statement output, rather than lookup table.
{
- option_word |= SWITCH;
+ ACE_SET_BITS (option_word, SWITCH);
if ((option.total_switches = atoi (getopt.optarg)) <= 0)
ACE_ERROR ((LM_ERROR, "number of switches %s must be a positive number\n%e%a", getopt.optarg, usage, 1));
break;
}
- case 't': /* Enable the TYPE mode, allowing arbitrary user structures. */
+ case 't': // Enable the TYPE mode, allowing arbitrary user structures.
{
- option_word |= TYPE;
+ ACE_SET_BITS (option_word, TYPE);
+ break;
+ }
+ case 'T': // Don't print structure definition.
+ {
+ ACE_SET_BITS (option_word, NOTYPE);
break;
}
- case 'T': /* Don't print structure definition. */
- {
- option_word |= NOTYPE;
- break;
- }
- case 'v': /* Print out the version and quit. */
+ case 'v': // Print out the version and quit.
ACE_ERROR ((LM_ERROR, "%n: version %s\n%e\n%a", version_string, usage, 1));
- case 'Z': /* Set the class name. */
+ case 'Z': // Set the class name.
{
class_name = getopt.optarg;
break;
@@ -503,110 +511,146 @@ Options::operator() (int argc, char *argv[])
ACE_ERROR ((LM_ERROR, "Extra trailing arguments to %n.\n%e%a", usage, 1));
}
+// True if option enable, else false.
+
int
-Options::operator[] (Option_Type option) /* True if option enable, else false. */
+Options::operator[] (Option_Type option)
{
return option_word & option;
}
+// Enables option OPT.
+
void
-Options::operator = (enum Option_Type opt) /* Enables option OPT. */
+Options::operator = (enum Option_Type opt)
{
- option_word |= opt;
+ ACE_SET_BITS (option_word, opt);
}
+// Disables option OPT.
+
void
-Options::operator != (enum Option_Type opt) /* Disables option OPT. */
+Options::operator != (enum Option_Type opt)
{
- option_word &= ~opt;
+ ACE_CLR_BITS (option_word, opt);
}
+// Initializes the key Iterator.
+
void
-Options::reset (void) /* Initializes the key Iterator. */
+Options::reset (void)
{
key_pos = 0;
}
+// Returns current key_position and advanced index.
+
int
-Options::get (void) /* Returns current key_position and advanced index. */
+Options::get (void)
{
return key_positions[key_pos++];
}
+// Sets the size of the table size.
+
void
-Options::set_asso_max (int r) /* Sets the size of the table size. */
+Options::set_asso_max (int r)
{
size = r;
}
+// Returns the size of the table size.
+
int
-Options::get_asso_max (void) /* Returns the size of the table size. */
+Options::get_asso_max (void)
{
return size;
}
+// Returns total distinct key positions.
+
int
-Options::get_max_keysig_size (void) /* Returns total distinct key positions. */
+Options::get_max_keysig_size (void)
{
return total_keysig_size;
}
+// Sets total distinct key positions.
+
void
-Options::set_keysig_size (int a_size) /* Sets total distinct key positions. */
+Options::set_keysig_size (int a_size)
{
total_keysig_size = a_size;
}
+// Returns the jump value.
+
int
-Options::get_jump (void) /* Returns the jump value. */
+Options::get_jump (void)
{
return jump;
}
+// Returns the generated function name.
+
const char *
-Options::get_function_name (void) /* Returns the generated function name. */
+Options::get_function_name (void)
{
return function_name;
}
+// Returns the keyword key name.
+
const char *
-Options::get_key_name (void) /* Returns the keyword key name. */
+Options::get_key_name (void)
{
return key_name;
}
+// Returns the hash function name.
+
const char *
-Options::get_hash_name (void) /* Returns the hash function name. */
+Options::get_hash_name (void)
{
return hash_name;
}
+// Returns the generated class name.
+
const char *
-Options::get_class_name (void) /* Returns the generated class name. */
+Options::get_class_name (void)
{
return class_name;
}
+// Returns the initial associated character value.
+
int
-Options::initial_value (void) /* Returns the initial associated character value. */
+Options::initial_value (void)
{
return initial_asso_value;
}
+// Returns the iterations value.
+
int
-Options::get_iterations (void) /* Returns the iterations value. */
+Options::get_iterations (void)
{
return iterations;
}
+// Returns the string used to delimit keywords from other attributes.
+
const char *
-Options::get_delimiter () /* Returns the string used to delimit keywords from other attributes. */
+Options::get_delimiter (void)
{
return delimiters;
}
+// Gets the total number of switch statements to generate.
+
int
-Options::get_total_switches () /* Gets the total number of switch statements to generate. */
+Options::get_total_switches (void)
{
return total_switches;
}
diff --git a/apps/gperf/src/Options.h b/apps/gperf/src/Options.h
index 22579aac4d4..9ea3634683c 100644
--- a/apps/gperf/src/Options.h
+++ b/apps/gperf/src/Options.h
@@ -1,89 +1,88 @@
/* -*- C++ -*- */
// $Id$
-/* This may look like C code, but it is really -*- C++ -*- */
+// Handles parsing the Options provided to the user.
-/* Handles parsing the Options provided to the user.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
-
-/* This module provides a uniform interface to the various options
- available to a user of the gperf hash function generator. In
- addition to the run-time options, found in the Option_Type below,
- there is also the hash table Size and the Keys to be used in the
- hashing. The overall design of this module was an experiment in
- using C++ classes as a mechanism to enhance centralization of
- option and and error handling, which tend to get out of hand in a C
- program. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
-#ifndef options_h
-#define options_h 1
+#if !defined (OPTIONS_H)
+#define OPTIONS_H
#include "ace/Log_Msg.h"
-/* Enumerate the potential debugging Options. */
+// Enumerate the potential debugging Options.
enum Option_Type
{
- DEBUG = 01, /* Enable debugging (prints diagnostics to stderr). */
- ORDER = 02, /* Apply ordering heuristic to speed-up search time. */
- ANSI = 04, /* Generate ANSI prototypes. */
- ALLCHARS = 010, /* Use all characters in hash function. */
- GNU = 020, /* Assume GNU extensions (primarily function inline). */
- TYPE = 040, /* Handle user-defined type structured keyword input. */
- RANDOM = 0100, /* Randomly initialize the associated values table. */
- DEFAULTCHARS = 0200, /* Make default char positions be 1,$ (end of keyword). */
- SWITCH = 0400, /* Generate switch output to save space. */
- POINTER = 01000, /* Have in_word_set function return pointer, not boolean. */
- NOLENGTH = 02000, /* Don't include keyword length in hash computations. */
- LENTABLE = 04000, /* Generate a length table for string comparison. */
- DUP = 010000, /* Handle duplicate hash values for keywords. */
- FAST = 020000, /* Generate the hash function ``fast.'' */
- NOTYPE = 040000, /* Don't include user-defined type definition in output -- it's already defined elsewhere. */
- COMP = 0100000, /* Generate strncmp rather than strcmp. */
- GLOBAL = 0200000, /* Make the keyword table a global variable. */
- CONST = 0400000, /* Make the generated tables readonly (const). */
- CPLUSPLUS = 01000000, /* Generate C++ code. */
- C = 02000000, /* Generate C code. */
- ENUM = 04000000, /* Use enum for constants. */
- STRCASECMP = 010000000, /* Use the case insensitive comparison. */
- OPTIMIZE = 020000000, /* Assume all input keywords are in the keyset. */
- ADA = 040000000 /* Generate Ada code. */
+ DEBUG = 01, // Enable debugging (prints diagnostics to stderr).
+ ORDER = 02, // Apply ordering heuristic to speed-up search time.
+ ANSI = 04, // Generate ANSI prototypes.
+ ALLCHARS = 010, // Use all characters in hash function.
+ GNU = 020, // Assume GNU extensions (primarily function inline).
+ TYPE = 040, // Handle user-defined type structured keyword input.
+ RANDOM = 0100, // Randomly initialize the associated values table.
+ DEFAULTCHARS = 0200, // Make default char positions be 1,$ (end of keyword).
+ SWITCH = 0400, // Generate switch output to save space.
+ POINTER = 01000, // Have in_word_set function return pointer, not boolean.
+ NOLENGTH = 02000, // Don't include keyword length in hash computations.
+ LENTABLE = 04000, // Generate a length table for string comparison.
+ DUP = 010000, // Handle duplicate hash values for keywords.
+ FAST = 020000, // Generate the hash function ``fast.''
+ NOTYPE = 040000, // Don't include user-defined type definition in output -- it's already defined elsewhere.
+ COMP = 0100000, // Generate strncmp rather than strcmp.
+ GLOBAL = 0200000, // Make the keyword table a global variable.
+ CONST = 0400000, // Make the generated tables readonly (const).
+ CPLUSPLUS = 01000000, // Generate C++ code.
+ C = 02000000, // Generate C code.
+ ENUM = 04000000, // Use enum for constants.
+ STRCASECMP = 010000000, // Use the case insensitive comparison.
+ OPTIMIZE = 020000000, // Assume all input keywords are in the keyset.
+ ADA = 040000000 // Generate Ada code.
};
-/* Define some useful constants (these don't really belong here, but I'm
- not sure where else to put them!). These should be consts, but g++
- doesn't seem to do the right thing with them at the moment... ;-( */
+// Define some useful constants (these don't really belong here, but
+// I'm not sure where else to put them!). These should be consts, but
+// g++ doesn't seem to do the right thing with them at the
+// moment... ;-(
enum
{
- MAX_KEY_POS = 128 - 1, /* Max size of each word's key set. */
- WORD_START = 1, /* Signals the start of a word. */
- WORD_END = 0, /* Signals the end of a word. */
- EOS = MAX_KEY_POS /* Signals end of the key list. */
+ MAX_KEY_POS = 128 - 1, // Max size of each word's key set.
+ WORD_START = 1, // Signals the start of a word.
+ WORD_END = 0, // Signals the end of a word.
+ EOS = MAX_KEY_POS // Signals end of the key list.
};
-/* Class manager for gperf program Options. */
-
+// @@ The Options class should be changed to use the Singleton pattern.
class Options
{
+ // = TITLE
+ // This class provides a uniform interface to the various options
+ // available to a user of the gperf hash function generator.
+ // = DESCRIPTION
+ // In addition to the run-time options, found in the <Option_Type>
+ // there is also the hash table Size and the Keys to be used in
+ // the hashing. The overall design of this module was an
+ // experiment in using C++ classes as a mechanism to enhance
+ // centralization of option and and error handling.
public:
Options (void);
~Options (void);
@@ -109,32 +108,67 @@ public:
static const char *get_delimiter (void);
private:
- static int option_word; /* Holds the user-specified Options. */
- static int total_switches; /* Number of switch statements to generate. */
- static int total_keysig_size; /* Total number of distinct key_positions. */
- static int size; /* Range of the hash table. */
- static int key_pos; /* Tracks current key position for Iterator. */
- static int jump; /* Jump length when trying alternative values. */
- static int initial_asso_value; /* Initial value for asso_values table. */
- static int argument_count; /* Records count of command-line arguments. */
- static int iterations; /* Amount to iterate when a collision occurs. */
- static char **argument_vector; /* Stores a pointer to command-line vector. */
- static const char *function_name; /* Names used for generated lookup function. */
- static const char *key_name; /* Name used for keyword key. */
- static const char *class_name; /* Name used for generated C++ class. */
- static const char *hash_name; /* Name used for generated hash function. */
- static const char *delimiters; /* Separates keywords from other attributes. */
- static char key_positions[MAX_KEY_POS]; /* Contains user-specified key choices. */
- static int key_sort (char *base, int len); /* Sorts key positions in REVERSE order. */
- static void usage (void); /* Prints proper program usage. */
+ static int option_word;
+ // Holds the user-specified Options.
+
+ static int total_switches;
+ // Number of switch statements to generate.
+
+ static int total_keysig_size;
+ // Total number of distinct key_positions.
+
+ static int size;
+ // Range of the hash table.
+
+ static int key_pos;
+ // Tracks current key position for Iterator.
+
+ static int jump;
+ // Jump length when trying alternative values.
+
+ static int initial_asso_value;
+ // Initial value for asso_values table.
+
+ static int argument_count;
+ // Records count of command-line arguments.
+
+ static int iterations;
+ // Amount to iterate when a collision occurs.
+
+ static char **argument_vector;
+ // Stores a pointer to command-line vector.
+
+ static const char *function_name;
+ // Names used for generated lookup function.
+
+ static const char *key_name;
+ // Name used for keyword key.
+
+ static const char *class_name;
+ // Name used for generated C++ class.
+
+ static const char *hash_name;
+ // Name used for generated hash function.
+
+ static const char *delimiters;
+ // Separates keywords from other attributes.
+
+ static char key_positions[MAX_KEY_POS];
+ // Contains user-specified key choices.
+
+ static int key_sort (char *base, int len);
+ // Sorts key positions in REVERSE order.
+
+ static void usage (void);
+ // Prints proper program usage.
};
-/* Global option coordinator for the entire program. */
+// Global option coordinator for the entire program.
extern Options option;
-/* Set to 1 if your want to stack-allocate some large arrays. */
-#ifndef LARGE_STACK_ARRAYS
+// Set to 1 if your want to stack-allocate some large arrays.
+#if !defined (LARGE_STACK_ARRAYS)
#define LARGE_STACK_ARRAYS 0
-#endif
+#endif /* LARGE_STACK_ARRAYS */
-#endif
+#endif /* OPTIONS_H */
diff --git a/apps/gperf/src/Vectors.cpp b/apps/gperf/src/Vectors.cpp
index 218ebc9aa64..409a8708e85 100644
--- a/apps/gperf/src/Vectors.cpp
+++ b/apps/gperf/src/Vectors.cpp
@@ -1,28 +1,25 @@
/* This may look like C code, but it is really -*- C++ -*- */
// $Id$
-
-/* Static class data members that are shared between several classes via
- inheritance.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "Vectors.h"
diff --git a/apps/gperf/src/Vectors.h b/apps/gperf/src/Vectors.h
index c557c7afe56..96530299aa9 100644
--- a/apps/gperf/src/Vectors.h
+++ b/apps/gperf/src/Vectors.h
@@ -3,37 +3,37 @@
#include <stdio.h>
-/* This may look like C code, but it is really -*- C++ -*- */
-
-/* Static class data members that are shared between several classes via
- inheritance.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
-#ifndef vectors_h
-#define vectors_h 1
+#if !defined (VECTORS_H)
+#define VECTORS_H
static const int ALPHA_SIZE = 128;
-struct Vectors
+class Vectors
{
+ // = TITLE
+ // Static class data members that are shared between several
+ // classes via inheritance.
+public:
static int occurrences[ALPHA_SIZE];
// Counts occurrences of each key set character.
@@ -41,4 +41,4 @@ struct Vectors
// Value associated with each character.
};
-#endif
+#endif /* VECTORS_H */
diff --git a/apps/gperf/src/Version.cpp b/apps/gperf/src/Version.cpp
index b26c55e4124..ffa1e93397e 100644
--- a/apps/gperf/src/Version.cpp
+++ b/apps/gperf/src/Version.cpp
@@ -1,21 +1,20 @@
-/* Current program version number.
// $Id$
+// Current program version number.
-
- Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
diff --git a/apps/gperf/src/gperf.cpp b/apps/gperf/src/gperf.cpp
index cb8577f950d..7fbe88fc423 100644
--- a/apps/gperf/src/gperf.cpp
+++ b/apps/gperf/src/gperf.cpp
@@ -1,24 +1,26 @@
-/* Driver program for the Gen_Perf hash function generator Copyright
// $Id$
- (C) 1989 Free Software Foundation, Inc. written by Douglas
- C. Schmidt (schmidt@ics.uci.edu)
+// Driver program for the Gen_Perf hash function generator
+
+/* Copyright (C) 1989 Free Software Foundation, Inc. written by
+ Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
// Simple driver program for the Gen_Perf.hash function generator.
// All the hard work is done in class Gen_Perf and its class methods.
@@ -29,27 +31,29 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
int
main (int argc, char *argv[])
{
-
struct tm *tm;
- time_t clock;
+ time_t clock;
time (&clock);
tm = localtime (&clock);
- printf ("/* starting time is %d:%02d:%02d */\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
+ ACE_OS::printf ("/* starting time is %d:%02d:%02d */\n",
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
-#if defined(RLIMIT_STACK) && LARGE_STACK_ARRAYS
- /* Get rid of any avoidable limit on stack size. */
+#if defined (RLIMIT_STACK) && defined (LARGE_STACK_ARRAYS)
+ // Get rid of any avoidable limit on stack size.
{
struct rlimit rlim;
- /* Set the stack limit huge so that alloca does not fail. */
- getrlimit (RLIMIT_STACK, &rlim);
+ // Set the stack limit huge so that alloca does not fail.
+ ACE_OS::getrlimit (RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max;
- setrlimit (RLIMIT_STACK, &rlim);
+ ACE_OS::setrlimit (RLIMIT_STACK, &rlim);
}
-#endif /* RLIMIT_STACK */
+#endif /* RLIMIT_STACK && LARGE_STACK_ARRAYS */
- /* Sets the Options. */
+ // Sets the Options.
option (argc, argv);
// Initializes the key word list.
@@ -61,6 +65,11 @@ main (int argc, char *argv[])
time (&clock);
tm = localtime (&clock);
- printf ("/* ending time is %d:%02d:%02d */\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ ACE_OS::printf ("/* ending time is %d:%02d:%02d */\n",
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
+
return status;
}
diff --git a/apps/gperf/src/new.cpp b/apps/gperf/src/new.cpp
index 25cb527a98a..14753699491 100644
--- a/apps/gperf/src/new.cpp
+++ b/apps/gperf/src/new.cpp
@@ -1,63 +1,73 @@
-/* Defines a buffered memory allocation abstraction that reduces calls to
// $Id$
- malloc.
- Copyright (C) 1989 Free Software Foundation, Inc.
+// Defines a buffered memory allocation abstraction that reduces calls
+// to malloc.
+
+/* Copyright (C) 1989 Free Software Foundation, Inc.
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
This file is part of GNU GPERF.
-GNU GPERF is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+GNU GPERF is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 1, or (at your option) any
+later version.
-GNU GPERF is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GNU GPERF is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU GPERF; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111,
+USA. */
#include "Options.h"
-/* Determine default alignment. If your C++ compiler does not like
- this then try something like #define DEFAULT_ALIGNMENT 8. */
+// Determine default alignment. If your C++ compiler does not like
+// this then try something like #define DEFAULT_ALIGNMENT 8.
struct fooalign {char x; double d;};
const int ALIGNMENT = ((char *)&((struct fooalign *) 0)->d - (char *)0);
-/* Provide an abstraction that cuts down on the number of calls to NEW
- by buffering the memory pool from which strings are allocated. */
+// Provide an abstraction that cuts down on the number of calls to NEW
+// by buffering the memory pool from which strings are allocated.
void *
operator new (size_t size)
{
- static char *buf_start = 0; /* Large array used to reduce calls to NEW. */
- static char *buf_end = 0; /* Indicates end of BUF_START. */
- static int buf_size = 4 * BUFSIZ; /* Size of buffer pointed to by BUF_START. */
- char *temp;
+ // @@ This function should probably be replaced with something from
+ // ACE, e.g., some type of ACE_Memory_Allocator.
+
+ static char *buf_start = 0; // Large array used to reduce calls to NEW.
+ static char *buf_end = 0; // Indicates end of BUF_START.
+ static int buf_size = 4 * BUFSIZ; // Size of buffer pointed to by BUF_START.
+ char *temp;
- /* Align this on correct boundaries, just to be safe... */
+ // Align this on correct boundaries, just to be safe...
size = ((size + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT;
- /* If we are about to overflow our buffer we'll just grab another
- chunk of memory. Since we never free the original memory it
- doesn't matter that no one points to the beginning of that
- chunk. Note we use a heuristic that grows the buffer either by
- size of the request or by twice the previous size, whichever is
- larger. */
+ // If we are about to overflow our buffer we'll just grab another
+ // chunk of memory. Since we never free the original memory it
+ // doesn't matter that no one points to the beginning of that
+ // chunk. Note we use a heuristic that grows the buffer either by
+ // size of the request or by twice the previous size, whichever is
+ // larger.
if (buf_start + size >= buf_end)
{
buf_size *= 2;
if (buf_size < size)
buf_size = size;
- if (buf_start = (char *)malloc (buf_size))
+ if (buf_start = (char *) malloc (buf_size))
buf_end = buf_start + buf_size;
else
- ACE_ERROR ((LM_ERROR, "Virtual memory failed at %s, %s in function %s\n%a", __FILE__, __LINE__, "operator new", 1));
+ ACE_ERROR ((LM_ERROR,
+ "Virtual memory failed at %s, %s in function %s\n%a",
+ __FILE__,
+ __LINE__,
+ "operator new",
+ 1));
}
temp = buf_start;
@@ -65,11 +75,11 @@ operator new (size_t size)
return temp;
}
-/* We need this deletion operator in order to make the linker happy. */
+// We need this deletion operator in order to make the linker happy.
void
operator delete (void *ptr)
{
- // We cannot call free here, as it doesn't match the mallocs.
- // free ((char *) ptr);
+ // We cannot call free here, as it doesn't match the mallocs. free
+ // ((char *) ptr);
}
diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp
index efd0a777a73..abe6d51e088 100644
--- a/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp
+++ b/examples/IPC_SAP/SOCK_SAP/CPP-inserver-poll.cpp
@@ -10,8 +10,11 @@
#if defined (ACE_HAS_POLL)
+// Should we be verbose?
+static int verbose = 0;
+
// Max number of open handles.
-const int MAX_HANDLES = 200;
+static const int MAX_HANDLES = 200;
struct Buffer_Info
{
@@ -41,10 +44,10 @@ init_poll_array (void)
}
static int
-init_buffer (ACE_HANDLE handle)
+init_buffer (size_t index)
{
- if (ACE::recv_n (handle,
- (void *) &buffer_array[handle].len_,
+ if (ACE::recv_n (poll_array[index].fd,
+ (void *) &buffer_array[index].len_,
sizeof (ACE_UINT32)) != sizeof (ACE_UINT32))
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) %p\n",
@@ -52,13 +55,14 @@ init_buffer (ACE_HANDLE handle)
0);
else
{
- buffer_array[handle].len_ =
- ntohl (buffer_array[handle].len_);
+ buffer_array[index].len_ =
+ ntohl (buffer_array[index].len_);
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) reading messages of size %d\n",
- buffer_array[handle].len_));
- buffer_array[handle].buf_ =
- ACE_OS::malloc (buffer_array[handle].len_);
+ buffer_array[index].len_));
+ ACE_ALLOCATOR_RETURN (buffer_array[index].buf_,
+ ACE_OS::malloc (buffer_array[index].len_),
+ -1);
}
}
@@ -68,19 +72,29 @@ handle_data (size_t n_handles)
// Handle pending logging messages first (s_handle + 1 is guaranteed
// to be lowest client descriptor).
- for (ACE_HANDLE handle = 1; handle < n_handles; handle++)
+ for (size_t index = 1; index < n_handles; index++)
{
- if (ACE_BIT_ENABLED (poll_array[handle].revents, POLLIN))
+ if (ACE_BIT_ENABLED (poll_array[index].revents, POLLIN))
{
// Read data from client (terminate on error).
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) buf = %d, handle = %d\n",
+ buffer_array[index].buf_,
+ poll_array[index].fd));
// First time in -- gotta initialize the buffer.
- if (buffer_array[handle].buf_ == 0)
- init_buffer (handle);
+ if (buffer_array[index].buf_ == 0
+ && init_buffer (index) == -1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) %p\n",
+ "init_buffer"));
+ continue;
+ }
- ssize_t n = ACE::recv (poll_array[handle].fd,
- buffer_array[handle].buf_,
- buffer_array[handle].len_);
+ ssize_t n = ACE::recv (poll_array[index].fd,
+ buffer_array[index].buf_,
+ buffer_array[index].len_);
// <recv> will not block in this case!
if (n == -1)
@@ -89,21 +103,24 @@ handle_data (size_t n_handles)
"read failed"));
else if (n == 0)
{
- // Handle client connection shutdown.
- ACE_OS::close (poll_array[handle].fd);
- poll_array[handle].fd = poll_array[--n_handles].fd;
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) closing oneway server at handle %d\n",
+ poll_array[index].fd));
- ACE_OS::free ((void *) buffer_array[handle].buf_);
- buffer_array[handle].buf_ = 0;
+ // Handle client connection shutdown.
+ ACE_OS::close (poll_array[index].fd);
+ poll_array[index].fd = poll_array[--n_handles].fd;
- // Send handshake back to client to unblock it.
- if (ACE::send (poll_array[handle].fd, "", 1) != 1)
- ACE_ERROR ((LM_ERROR, "%p\n", "send_n"));
+ ACE_OS::free ((void *) buffer_array[index].buf_);
+ buffer_array[index].buf_ = 0;
+ buffer_array[index].len_ = 0;
}
- else
- ACE_OS::printf ("%*s", n, buffer_array[handle].buf_), fflush (stdout);
+ else if (verbose)
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) %*s",
+ n,
+ buffer_array[index].buf_));
}
- ACE_OS::fflush (stdout);
}
}
@@ -129,8 +146,9 @@ handle_connections (ACE_SOCK_Acceptor &peer_acceptor,
const char *s = client.get_host_name ();
ACE_ASSERT (s != 0);
- ACE_OS::printf ("client %s\n", s);
- ACE_OS::fflush (stdout);
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) client %s\n",
+ s));
poll_array[n_handles++].fd = new_stream.get_handle ();
}
}
@@ -139,8 +157,10 @@ handle_connections (ACE_SOCK_Acceptor &peer_acceptor,
int
main (int, char *[])
{
+ u_short port = ACE_DEFAULT_SERVER_PORT + 1;
+
// Create a server end-point.
- ACE_INET_Addr addr (ACE_DEFAULT_SERVER_PORT);
+ ACE_INET_Addr addr (port);
ACE_SOCK_Acceptor peer_acceptor (addr);
ACE_HANDLE s_handle = peer_acceptor.get_handle ();
@@ -149,6 +169,10 @@ main (int, char *[])
poll_array[0].fd = s_handle;
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) starting oneway server at port %d\n",
+ port));
+
for (int n_handles = 1;;)
{
// Wait for client I/O events (handle interrupts).
diff --git a/performance-tests/Synch-Benchmarks/synch_driver.cpp b/performance-tests/Synch-Benchmarks/synch_driver.cpp
index 5ea17ff38d9..ccbb4674273 100644
--- a/performance-tests/Synch-Benchmarks/synch_driver.cpp
+++ b/performance-tests/Synch-Benchmarks/synch_driver.cpp
@@ -69,11 +69,14 @@ Benchmark_Test::run_test (void)
(options.t_flags () & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
this->orig_n_lwps_, this->n_lwps_, ACE_Thread::getconcurrency ()));
- int count = options.count ();
+ int count = options.count ();
float rate = count / (float (options.sleep_time ()));
- ACE_DEBUG ((LM_DEBUG, "to count = %d\nrate = %.3f ops/sec, per operation = %.2f usec\n",
- count, rate, (1.0e6 / rate) / synch_count));
+ ACE_DEBUG ((LM_DEBUG,
+ "to count = %d\nrate = %.3f ops/sec, per operation = %.2f usec\n",
+ count,
+ rate,
+ (1.0e6 / rate) / synch_count));
options.print_results ();
// Allow thread(s) to finish up.