summaryrefslogtreecommitdiff
path: root/ACE/apps/gperf/src
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2008-03-04 13:56:48 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2008-03-04 13:56:48 +0000
commitc4078c377d74290ebe4e66da0b4975da91732376 (patch)
tree1816ef391e42a07929304908ac0e21f4c2f6cb7b /ACE/apps/gperf/src
parent700d1c1a6be348c6c70a2085e559baeb8f4a62ea (diff)
downloadATCD-c4078c377d74290ebe4e66da0b4975da91732376.tar.gz
swap in externals for ACE and TAO
Diffstat (limited to 'ACE/apps/gperf/src')
-rw-r--r--ACE/apps/gperf/src/Bool_Array.cpp108
-rw-r--r--ACE/apps/gperf/src/Bool_Array.h75
-rw-r--r--ACE/apps/gperf/src/Gen_Perf.cpp458
-rw-r--r--ACE/apps/gperf/src/Gen_Perf.h81
-rw-r--r--ACE/apps/gperf/src/Hash_Table.cpp116
-rw-r--r--ACE/apps/gperf/src/Hash_Table.h66
-rw-r--r--ACE/apps/gperf/src/Iterator.cpp99
-rw-r--r--ACE/apps/gperf/src/Iterator.h80
-rw-r--r--ACE/apps/gperf/src/Key_List.cpp1957
-rw-r--r--ACE/apps/gperf/src/Key_List.h173
-rw-r--r--ACE/apps/gperf/src/List_Node.cpp134
-rw-r--r--ACE/apps/gperf/src/List_Node.h80
-rw-r--r--ACE/apps/gperf/src/Makefile.am56
-rw-r--r--ACE/apps/gperf/src/Options.cpp873
-rw-r--r--ACE/apps/gperf/src/Options.h190
-rw-r--r--ACE/apps/gperf/src/Vectors.cpp36
-rw-r--r--ACE/apps/gperf/src/Vectors.h61
-rw-r--r--ACE/apps/gperf/src/Version.cpp30
-rw-r--r--ACE/apps/gperf/src/gperf.cpp88
-rw-r--r--ACE/apps/gperf/src/gperf.mpc20
20 files changed, 0 insertions, 4781 deletions
diff --git a/ACE/apps/gperf/src/Bool_Array.cpp b/ACE/apps/gperf/src/Bool_Array.cpp
deleted file mode 100644
index 668f0cd0016..00000000000
--- a/ACE/apps/gperf/src/Bool_Array.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Fast lookup table abstraction implemented as an Iteration Number Array
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Bool_Array.h"
-#include "ace/OS_NS_string.h"
-
-ACE_RCSID(src, Bool_Array, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "ace/OS_Memory.h"
-
-// Prints out debugging diagnostics.
-
-Bool_Array::~Bool_Array (void)
-{
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "\ndumping boolean array information\n"
- "size = %u\niteration number = %u\nend of array dump\n",
- size_,
- generation_number_));
- delete [] this->storage_array_;
-}
-
-Bool_Array::Bool_Array (void)
- : storage_array_ (0),
- generation_number_ (0),
- size_ (0)
-{
-}
-
-int
-Bool_Array::open (u_long s)
-{
- this->generation_number_ = 1;
- this->size_ = s;
-
- ACE_NEW_RETURN (storage_array_,
- u_long[s],
- -1);
-
- ACE_OS::memset (storage_array_,
- 0,
- s * sizeof *storage_array_);
-
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "\nbool array size = %u, total bytes = %u\n",
- size_,
- size_ * (int) sizeof *storage_array_));
- return 0;
-}
-
-int
-Bool_Array::find (u_long slot)
-{
- if (storage_array_[slot] == generation_number_)
- return 1;
- else
- {
- storage_array_[slot] = generation_number_;
- return 0;
- }
-}
-
-void
-Bool_Array::reset (void)
-{
- if (++generation_number_ == 0)
- {
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "(re-initializing bool_array)..."));
-
- this->generation_number_ = 1;
- ACE_OS::memset (storage_array_,
- 0,
- size_ * sizeof *storage_array_);
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "done\n"));
- }
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Bool_Array.h b/ACE/apps/gperf/src/Bool_Array.h
deleted file mode 100644
index da76fd7d3e6..00000000000
--- a/ACE/apps/gperf/src/Bool_Array.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef BOOL_ARRAY_H
-#define BOOL_ARRAY_H
-
-#include "ace/config-all.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "Options.h"
-
-#if defined (ACE_HAS_GPERF)
-
-class Bool_Array
-{
- // = TITLE
- // Efficient lookup table abstraction implemented as a "Generation
- // Number" Array.
- //
- // = DESCRIPTION
- // Uses a "Generation Numbering" implementation to minimize
- // initialization time.
-public:
- // = Initialization and termination methods.
- Bool_Array (void);
- // Constructor
-
- int open (u_long);
- // Initialize the array (requires O(n) time).
-
- ~Bool_Array (void);
- // Destructor.
-
- int find (u_long value);
- // Locate the <value> in the array (requires O(1) time).
-
- void reset (void);
- // Reinitializes the array (requires O(1) time).
-
-private:
- unsigned long *storage_array_;
- // Initialization of the index space.
-
- unsigned long generation_number_;
- // Keep track of the current Generation.
-
- unsigned long size_;
- // Keep track of array size.
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* BOOL_ARRAY_H */
diff --git a/ACE/apps/gperf/src/Gen_Perf.cpp b/ACE/apps/gperf/src/Gen_Perf.cpp
deleted file mode 100644
index 4f62eaecfae..00000000000
--- a/ACE/apps/gperf/src/Gen_Perf.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Gen_Perf.h"
-
-ACE_RCSID(src, Gen_Perf, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "Vectors.h"
-#include "ace/OS_NS_stdlib.h"
-#include "ace/OS_NS_time.h"
-#include "ace/OS_NS_stdio.h"
-#include "ace/OS_Memory.h"
-
-// Current release version.
-extern const 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!
-
-Gen_Perf::Gen_Perf (void)
- : fewest_collisions (0),
- num_done (1)
-{
-}
-
-// 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 set1 and set2 must be
-// ordered. Returns the length of the combined set.
-
-int
-Gen_Perf::compute_disjoint_union (char *set1, char *set2, char *set3)
-{
- char *base = set3;
-
- while (*set1 && *set2)
- if (*set1 == *set2)
- set1++, set2++;
- else
- {
- *set3 = *set1 < *set2 ? *set1++ : *set2++;
- if (set3 == base || *set3 != *(set3 - 1))
- set3++;
- }
-
- while (*set1)
- {
- *set3 = *set1++;
- if (set3 == base || *set3 != *(set3 - 1))
- set3++;
- }
-
- while (*set2)
- {
- *set3 = *set2++;
- if (set3 == base || *set3 != *(set3 - 1))
- set3++;
- }
- *set3 = '\0';
- return set3 - 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.
-
-void
-Gen_Perf::sort_set (char *union_set, int len)
-{
- for (int i = 0, j = len - 1; i < j; i++)
- {
- int curr, tmp;
-
- for (curr = i + 1, tmp = (int) union_set[curr];
- curr > 0
- && Vectors::occurrences[tmp] < Vectors::occurrences[(int) union_set[curr - 1]];
- curr--)
- union_set[curr] = union_set[curr - 1];
-
- union_set[curr] = static_cast<char> (tmp);
- }
-}
-
-// Generate a keysig's hash value.
-
-int
-Gen_Perf::hash (List_Node *key_node)
-{
- int sum = option[NOLENGTH] ? 0 : key_node->length;
-
- for (char *ptr = key_node->keysig; *ptr; ptr++)
- sum += Vectors::asso_values[(int) *ptr];
-
- key_node->hash_value = sum;
- return sum;
-}
-
-// 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)
-{
- int original_char = Vectors::asso_values[(int) c];
- int total_iterations;
-
- if (!option[FAST])
- total_iterations = option.asso_max ();
- else
- {
- total_iterations = option.iterations ();
-
- if (total_iterations == 0)
- total_iterations = this->key_list.keyword_list_length ();
- }
-
- // Try all legal associated values.
-
- for (int i = total_iterations - 1; i >= 0; i--)
- {
- int collisions = 0;
-
- Vectors::asso_values[(int) c] = Vectors::asso_values[(int) c] +
- (option.jump () ? option.jump () : ACE_OS::rand ()) & option.asso_max () - 1;
-
- // 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!
-
- for (List_Node *ptr = this->key_list.head;
- this->char_search.find (this->hash (ptr)) == 0
- || ++collisions < fewest_collisions;
- ptr = ptr->next)
- if (ptr == curr)
- {
- fewest_collisions = collisions;
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "- resolved after %d iterations",
- total_iterations - i));
- return 0;
- }
- }
-
- // Restore original values, no more tries.
- Vectors::asso_values[(int) c] = original_char;
- // If we're this far it's time to try the next character....
- return 1;
-}
-
-// Change a character value, try least-used characters first.
-
-int
-Gen_Perf::change (List_Node *prior, List_Node *curr)
-{
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "collision on keyword #%d, prior = \"%s\", curr = \"%s\" hash = %d\n",
- num_done,
- prior->key,
- curr->key,
- curr->hash_value));
- Gen_Perf::sort_set (this->union_set,
- compute_disjoint_union (prior->keysig,
- curr->keysig,
- this->union_set));
-
- // Try changing some values, if change doesn't alter other values
- // continue normal action.
- fewest_collisions++;
-
- for (char *temp = union_set; *temp != '\0'; temp++)
- if (affects_prev (*temp, curr) == 0)
- {
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- " by changing asso_value['%c'] (char #%d) to %d\n",
- *temp,
- temp - union_set + 1,
- Vectors::asso_values[(int) *temp]));
- // Good, doesn't affect previous hash values, we'll take it.
- return 0;
- }
-
- for (List_Node *ptr = this->key_list.head;
- ptr != curr;
- ptr = ptr->next)
- this->hash (ptr);
-
- this->hash (curr);
-
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "** collision not resolved after %d iterations, %d duplicates remain, continuing...\n",
- !option[FAST] ? option.asso_max () : option.iterations () ? option.iterations () : this->key_list.keyword_list_length (),
- fewest_collisions + this->key_list.total_duplicates));
- return 0;
-}
-
-int
-Gen_Perf::open (void)
-{
- if (this->key_list.read_keys () == -1)
- return -1;
-
- if (option[ORDER])
- this->key_list.reorder ();
-
- int asso_value_max = option.asso_max ();
- int non_linked_length = this->key_list.keyword_list_length ();
-
- if (asso_value_max == 0)
- asso_value_max = non_linked_length;
- else if (asso_value_max > 0)
- asso_value_max *= non_linked_length;
- else // if (asso_value_max < 0)
- asso_value_max = non_linked_length / -asso_value_max;
-
- option.asso_max (ACE_POW (asso_value_max));
-
- if (option[RANDOM])
- {
- ACE_OS::srand ((u_int) ACE_OS::time (0));
-
- for (int i = 0; i < ACE_STANDARD_CHARACTER_SET_SIZE; i++)
- Vectors::asso_values[i] = (ACE_OS::rand () & asso_value_max - 1);
- }
- else
- {
- int asso_value = option.initial_value ();
-
- // Initialize array if user requests non-zero default.
- if (asso_value)
- for (int i = ACE_STANDARD_CHARACTER_SET_SIZE - 1; i >= 0; i--)
- Vectors::asso_values[i] = asso_value & option.asso_max () - 1;
- }
-
- this->max_hash_value = this->key_list.max_key_length ()
- + option.asso_max ()
- * option.max_keysig_size ();
-
- ACE_NEW_RETURN (this->union_set,
- char[2 * option.max_keysig_size () + 1],
- -1);
- ACE_OS::printf ("/* ");
-
- if (option[C])
- ACE_OS::printf ("C");
-
- else if (option[CPLUSPLUS])
- ACE_OS::printf ("C++");
-
- ACE_OS::printf (" code produced by gperf version %s */\n",
- version_string);
- Options::print_options ();
-
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "total non-linked keys = %d\n"
- "total duplicates = %d\n"
- "maximum associated value is %d\n"
- "maximum size of generated hash table is %d\n",
- non_linked_length,
- this->key_list.total_duplicates,
- asso_value_max,
- max_hash_value));
- if (this->char_search.open (max_hash_value + 1) == -1)
- return -1;
- return 0;
-}
-
-// For binary search, do normal string sort on the keys, and then
-// assign hash values from 0 to N-1. Then go ahead with the normal
-// logic that is there for perfect hashing.
-int
-Gen_Perf::compute_binary_search (void)
-{
- // Do a string sort.
- this->key_list.string_sort ();
-
- // Assign hash values.
- List_Node *curr;
- int hash_value;
- for (hash_value = 0, curr = this->key_list.head;
- curr != 0;
- curr = curr->next, hash_value++)
- {
- curr->hash_value = hash_value;
- }
-
- return 0;
-}
-
-int
-Gen_Perf::compute_linear_search (void)
-{
- // Convert the list of keys to a linear list without
- // equivalence classes.
- this->key_list.string_sort ();
-
- // Assign hash values.
- List_Node *curr;
- int hash_value;
- for (hash_value = 0, curr = this->key_list.head;
- curr != 0;
- curr = curr->next, hash_value++)
- {
- curr->hash_value = hash_value;
- }
- return 0;
-}
-
-int
-Gen_Perf::compute_perfect_hash (void)
-{
- List_Node *curr;
-
- for (curr = this->key_list.head;
- curr != 0;
- curr = curr->next)
- {
- this->hash (curr);
-
- for (List_Node *ptr = this->key_list.head;
- ptr != curr;
- ptr = ptr->next)
- if (ptr->hash_value == curr->hash_value)
- {
- if (this->change (ptr, curr) == -1)
- return -1;
- break;
- }
- num_done++;
- }
-
- // Make one final check, just to make sure nothing weird happened...
-
- this->char_search.reset ();
-
- for (curr = this->key_list.head;
- curr;
- curr = curr->next)
- if (this->char_search.find (this->hash (curr)) != 0)
- if (option[DUP])
- // Keep track of the number of "dynamic" links (i.e., keys
- // that hash to the same value) so that we can use it later
- // when generating the output.
- this->key_list.total_duplicates++;
- 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",
- this->hash (curr)));
- return -1;
- }
-
- return 0;
-}
-
-// Does the hard stuff.... Initializes the Bool 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::run (void)
-{
- if (this->open () == -1)
- return 1;
-
- if (option[BINARYSEARCH])
- {
- if (this->compute_binary_search () == -1)
- return 1;
- }
- else if (option[LINEARSEARCH])
- {
- if (this->compute_linear_search () == -1)
- return 1;
- }
- else
- {
- if (this->compute_perfect_hash () == -1)
- 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.
- this->key_list.sort ();
- }
-
- this->key_list.output ();
- return 0;
-}
-
-// Prints out some diagnostics upon completion.
-
-Gen_Perf::~Gen_Perf (void)
-{
- if (option[DEBUGGING])
- {
- ACE_DEBUG ((LM_DEBUG,
- "\ndumping occurrence and associated values tables\n"));
- for (int i = 0; i < ACE_STANDARD_CHARACTER_SET_SIZE; i++)
- if (Vectors::occurrences[i])
- ACE_DEBUG ((LM_DEBUG,
- "Vectors::asso_values[%c] = %6d, Vectors::occurrences[%c] = %6d\n",
- i,
- Vectors::asso_values[i],
- i,
- Vectors::occurrences[i]));
- ACE_DEBUG ((LM_DEBUG,
- "end table dumping\n"));
- }
-
- delete [] this->union_set;
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Gen_Perf.h b/ACE/apps/gperf/src/Gen_Perf.h
deleted file mode 100644
index b9038face7a..00000000000
--- a/ACE/apps/gperf/src/Gen_Perf.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef GEN_PERF_H
-#define GEN_PERF_H
-
-#include "Options.h"
-#include "Key_List.h"
-#include "Bool_Array.h"
-
-#if defined (ACE_HAS_GPERF)
-
-class Gen_Perf
-{
- // = TITLE
- // Provides high-level routines to manipulate the keyword list
- // structures the code generation output.
-public:
- // = Initialization and termination methods.
- Gen_Perf (void);
- // Constructor.
-
- ~Gen_Perf (void);
- // Destructor
-
- int run (void);
- // Attempt to generate a perfect hash function.
-
-private:
- int open (void);
- int change (List_Node *prior, List_Node *curr);
- int affects_prev (char c, List_Node *curr);
- int compute_perfect_hash (void);
- int compute_binary_search (void);
- int compute_linear_search (void);
- static int hash (List_Node *key_node);
- static int compute_disjoint_union (char *s1, char *s2, char *s3);
- static void sort_set (char *union_set, int len);
-
- int max_hash_value;
- // Maximum possible hash value.
-
- int fewest_collisions;
- // Records fewest # of collisions for asso value.
-
- int num_done;
- // Number of keywords processed without a collision.
-
- char *union_set;
- // Disjoint union.
-
- Key_List key_list;
- // List of the keys we're trying to map into a perfect hash
- // function.
-
- Bool_Array char_search;
- // Table that keeps track of key collisions.
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* GEN_PERF_H */
diff --git a/ACE/apps/gperf/src/Hash_Table.cpp b/ACE/apps/gperf/src/Hash_Table.cpp
deleted file mode 100644
index 43c72552cee..00000000000
--- a/ACE/apps/gperf/src/Hash_Table.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Hash_Table.h"
-
-ACE_RCSID(src, Hash_Table, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "ace/ACE.h"
-#include "ace/OS_NS_string.h"
-#include "ace/OS_Memory.h"
-
-// The size of the hash table is always the smallest power of 2 >= the
-// size indicated by the user. This allows several optimizations,
-// including the use of double hashing and elimination of the mod
-// instruction. Note that the size had better be larger than the
-// number of items in the hash table, else there's trouble!!!
-
-Hash_Table::Hash_Table (size_t s)
- : size_ (ACE_POW (s)),
- collisions_ (0)
-{
- if (this->size_ == 0)
- this->size_ = 1;
- ACE_NEW (this->table_,
- List_Node*[this->size_]);
- ACE_OS::memset ((char *) this->table_,
- 0,
- this->size_ * sizeof *this->table_);
-}
-
-Hash_Table::~Hash_Table (void)
-{
- if (option[DEBUGGING])
- {
- size_t keysig_width = option.max_keysig_size () > ACE_OS::strlen ("keysig")
- ? option.max_keysig_size ()
- : ACE_OS::strlen ("keysig");
-
- ACE_DEBUG ((LM_DEBUG,
- "\ndumping the hash table\ntotal available table slots = %d, total bytes = %d, total collisions = %d\n"
- "location, %*s, keyword\n",
- this->size_,
- this->size_ * (int) sizeof *this->table_,
- this->collisions_,
- keysig_width,
- "keysig"));
-
- for (int i = static_cast<int> (this->size_ - 1); i >= 0; i--)
- if (this->table_[i])
- ACE_DEBUG ((LM_DEBUG,
- "%8d, %*s, %s\n",
- i,
- keysig_width,
- this->table_[i]->keysig,
- this->table_[i]->key));
- ACE_DEBUG ((LM_DEBUG,
- "end dumping hash table\n\n"));
- }
-
- delete [] this->table_;
-}
-
-// If the ITEM is already in the hash table return the item found in
-// the table. Otherwise inserts the ITEM, and returns FALSE. Uses
-// double hashing.
-
-List_Node *
-Hash_Table::find (List_Node *item,
- int ignore_length)
-{
- size_t hash_val = ACE::hash_pjw (item->keysig);
- // The following works since the hash table size_ is always a power
- // of 2...
- size_t size = this->size_ - 1;
- size_t probe;
- size_t increment = (hash_val ^ (ignore_length == 0 ? item->length : 0) | 1) & size;
-
- for (probe = hash_val & size;
- this->table_[probe]
- && (ACE_OS::strcmp (this->table_[probe]->keysig, item->keysig) != 0
- || (ignore_length == 0 && this->table_[probe]->length != item->length));
- probe = probe + increment & size)
- this->collisions_++;
-
- if (this->table_[probe])
- return this->table_[probe];
- else
- {
- this->table_[probe] = item;
- return 0;
- }
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Hash_Table.h b/ACE/apps/gperf/src/Hash_Table.h
deleted file mode 100644
index d8385858271..00000000000
--- a/ACE/apps/gperf/src/Hash_Table.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef HASH_TABLE_H
-#define HASH_TABLE_H
-
-#include "ace/config-all.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "Options.h"
-#include "List_Node.h"
-
-#if defined (ACE_HAS_GPERF)
-// @@ 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 (size_t s);
-
- ~Hash_Table (void);
-
- List_Node *find (List_Node *item, int ignore_length);
-
-private:
- List_Node **table_;
- // Vector of pointers to linked lists of List_Node's.
-
- size_t size_;
- // Size of the vector.
-
- int collisions_;
- // Find out how well our double hashing is working!
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* HASH_TABLE_H */
diff --git a/ACE/apps/gperf/src/Iterator.cpp b/ACE/apps/gperf/src/Iterator.cpp
deleted file mode 100644
index b4975a41bb5..00000000000
--- a/ACE/apps/gperf/src/Iterator.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Iterator.h"
-
-ACE_RCSID(src, Iterator, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "ace/OS_NS_ctype.h"
-
-// Constructor for Iterator.
-
-Iterator::Iterator (char *s,
- int lo,
- int hi,
- int word_end,
- int bad_val,
- int key_end)
- : str (s),
- end (key_end),
- end_word (word_end),
- error_value (bad_val),
- hi_bound (hi),
- lo_bound (lo)
-{
-}
-
-// Provide an Iterator, returning the ``next'' value from the list of
-// valid values given in the constructor.
-
-int
-Iterator::operator() (void)
-{
- // Variables to record the Iterator's status when handling ranges,
- // e.g., 3-12.
-
- static int size;
- static int curr_value;
- static int upper_bound;
-
- if (size)
- {
- if (++curr_value >= upper_bound)
- size = 0;
- return curr_value;
- }
- else
- {
- while (*str)
- switch (*str)
- {
- default: return error_value;
- case ',': str++; break;
- case '$': str++; return end_word;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- for (curr_value = 0; ACE_OS::ace_isdigit (*str); str++)
- curr_value = curr_value * 10 + *str - '0';
-
- if (*str == '-')
- {
-
- for (size = 1, upper_bound = 0;
- ACE_OS::ace_isdigit (*++str);
- upper_bound = upper_bound * 10 + *str - '0');
-
- if (upper_bound <= curr_value || upper_bound > hi_bound)
- return error_value;
- }
- return curr_value >= lo_bound && curr_value <= hi_bound
- ? curr_value : error_value;
- }
-
- return end;
- }
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Iterator.h b/ACE/apps/gperf/src/Iterator.h
deleted file mode 100644
index 03b9316205a..00000000000
--- a/ACE/apps/gperf/src/Iterator.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef ITERATOR_H
-#define ITERATOR_H
-
-#include "ace/config-all.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "Options.h"
-
-#if defined (ACE_HAS_GPERF)
-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);
- int operator () (void);
-
-private:
- char *str;
- // A pointer to the string provided by the user.
-
- int end;
- // Value returned after last key is processed.
-
- int end_word;
- // A value marking the abstract ``end of word'' (usually '$').
-
- int error_value;
- // Error value returned when input is syntactically erroneous.
-
- int hi_bound;
- // Greatest possible value, inclusive.
-
- int lo_bound;
- // Smallest possible value, inclusive.
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* ITERATOR_H */
diff --git a/ACE/apps/gperf/src/Key_List.cpp b/ACE/apps/gperf/src/Key_List.cpp
deleted file mode 100644
index 8eeecfd5551..00000000000
--- a/ACE/apps/gperf/src/Key_List.cpp
+++ /dev/null
@@ -1,1957 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Key_List.h"
-
-ACE_RCSID(src, Key_List, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "Hash_Table.h"
-#include "ace/Read_Buffer.h"
-#include "ace/Auto_Ptr.h"
-#include "ace/OS_Memory.h"
-#include "ace/OS_NS_stdio.h"
-#include "ace/OS_NS_string.h"
-
-// Default type for generated code.
-const char *const Key_List::default_array_type = "char *";
-
-// in_word_set return type, by default.
-const char *const Key_List::default_return_type = "char *";
-
-// How wide the printed field width must be to contain the maximum
-// hash value.
-int Key_List::field_width = 0;
-int Key_List::determined_[ACE_STANDARD_CHARACTER_SET_SIZE];
-
-// Destructor dumps diagnostics during debugging.
-
-Key_List::~Key_List (void)
-{
- if (option[DEBUGGING])
- this->dump ();
-
- // Free up all the nodes in the list.
- while (this->head != 0)
- {
- List_Node *temp;
-
- // Make sure to delete the linked nodes, as well.
- for (List_Node *ptr = this->head->link;
- ptr != 0;
- ptr = temp)
- {
- temp = ptr->link;
- delete ptr;
- }
-
- temp = this->head->next;
- delete this->head;
- this->head = temp;
- }
-}
-
-// 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::special_input (char delimiter)
-{
- int size = 80;
- char *buf = 0;
- ACE_NEW_RETURN (buf,
- char[size],
- 0);
- int c;
-
- for (int i = 0; (c = getchar ()) != EOF; i++)
- {
- if (c == '%')
- {
- c = getchar ();
- if (c == delimiter)
- {
- // Discard newline...
- while ((c = getchar ()) != '\n')
- continue;
-
- if (i == 0)
- {
- buf[0] = '\0';
- return buf;
- }
- else
- {
- buf[delimiter == '%' && buf[i - 2] == ';'
- ? i - 2
- : i - 1] = '\0';
- return buf;
- }
- }
- else
- buf[i++] = '%';
- }
- else if (i >= size)
- {
- // Yikes, time to grow the buffer!
-
- char *temp = 0;
- ACE_NEW_RETURN (temp,
- char[size *= 2],
- 0);
- for (int j = 0; j < i; j++)
- temp[j] = buf[j];
-
- delete [] buf;
- buf = temp;
- }
- buf[i] = static_cast<char> (c);
- }
-
- return 0;
-}
-
-// Stores any C/C++ source code that must be included verbatim into
-// the generated code output.
-
-char *
-Key_List::save_include_src (void)
-{
- int c = getchar ();
-
- if (c != '%')
- ACE_OS::ungetc (c, stdin);
- else if ((c = getchar ()) != '{')
- ACE_ERROR_RETURN ((LM_ERROR,
- "internal error, %c != '{' on line %l in file %N",
- c),
- 0);
- else
- return special_input ('}');
- return (char *) "";
-}
-
-// 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::array_type (void)
-{
- return special_input ('%');
-}
-
-// Sets up the Return_Type, the Struct_Tag type and the Array_Type
-// based upon various user Options.
-
-int
-Key_List::output_types (void)
-{
- if (option[TYPE])
- {
- array_type_ = array_type ();
- if (array_type_ == 0)
- // Something's wrong, but we'll catch it later on....
- return -1;
- else
- {
- // Yow, we've got a user-defined type...
- size_t struct_tag_length = ACE_OS::strcspn (array_type_,
- "{\n\0");
- if (option[POINTER]) // And it must return a pointer...
- {
- ACE_NEW_RETURN (return_type,
- char[struct_tag_length + 2],
- -1);
- ACE_OS::strncpy (return_type,
- array_type_,
- struct_tag_length);
- return_type[struct_tag_length] = '*';
- return_type[struct_tag_length + 1] = '\0';
- }
-
- ACE_NEW_RETURN (struct_tag,
- char[struct_tag_length + 2],
- -1);
- ACE_OS::strncpy (struct_tag,
- array_type_,
- struct_tag_length);
- if (struct_tag[struct_tag_length] != ' ')
- {
- struct_tag[struct_tag_length] = ' ';
- struct_tag_length++;
- }
- struct_tag[struct_tag_length] = '\0';
- }
- }
- else if (option[POINTER]) // Return a char *.
- return_type = (char *) Key_List::default_array_type;
- return 0;
-}
-
-// 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.
-
-int
-Key_List::read_keys (void)
-{
- this->include_src = this->save_include_src ();
- if (this->include_src == 0)
- return -1;
- else if (this->output_types () == -1)
- return -1;
- else
- {
- ACE_Read_Buffer input (stdin);
-
- char *buffer = input.read ('\n');
-
- if (buffer == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "No words in input file, did you forget to prepend %%%%"
- " or use -t accidentally?\n"),
- -1);
- // Read in all the keywords from the input file.
- else
- {
- List_Node *temp = 0;
- const char *delimiter = option.delimiter ();
- ACE_NEW_RETURN (this->head,
- List_Node (buffer,
- static_cast<int> (ACE_OS::strcspn (buffer,
- delimiter))),
- -1);
- for (temp = this->head;
- (0 != (buffer = input.read ('\n')))
- && ACE_OS::strcmp (buffer, "%%");
- temp = temp->next)
- {
- ACE_NEW_RETURN (temp->next,
- List_Node (buffer,
- static_cast<int> (ACE_OS::strcspn (buffer,
- delimiter))),
- -1);
- this->total_keys++;
- }
-
- // See if any additional source code is included at end of
- // this file.
- if (buffer)
- additional_code = 1;
-
- this->list_len = this->total_keys;
-
- // Make large hash table for efficiency.
- Hash_Table table (this->list_len * Key_List::TABLE_MULTIPLE);
- List_Node *trail = 0;
-
- // Test whether there are any links and also set the maximum
- // length an identifier in the keyword list.
-
- for (temp = head;
- temp != 0;
- temp = temp->next)
- {
- List_Node *ptr = table.find (temp, option[NOLENGTH]);
-
- // Check for static key 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 == 0)
- trail = temp;
- else
- {
- total_duplicates++;
- list_len--;
- trail->next = temp->next;
- temp->link = ptr->link;
- ptr->link = temp;
-
- // Complain if user hasn't enabled the duplicate
- // option.
- if (!option[DUP] || option[DEBUGGING])
- ACE_ERROR ((LM_ERROR,
- "Static key link: \"%s\" = \"%s\", with key set \"%s\".\n",
- temp->key,
- ptr->key,
- temp->keysig));
- }
-
- // 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;
- }
- }
-
- // Exit program if links exists and option[DUP] not set, since
- // we can't continue.
- if (total_duplicates)
- {
- if (option[DUP])
- {
- if (!option[MUTE])
- ACE_ERROR_RETURN ((LM_ERROR,
- "%d input keysigs have identical hash values, examine output carefully...\n",
- total_duplicates),
- 0);
- }
- else
- ACE_ERROR_RETURN ((LM_ERROR,
- "%d input keysigs have identical hash values,\ntry different key positions or use option -D.\n",
- total_duplicates),
- -1);
- }
- if (option[ALLCHARS])
- option.keysig_size (max_key_len);
- }
-
- return 0;
-}
-
-// 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)
-{
- if (!list1)
- return list2;
- else if (!list2)
- return list1;
- else if (occurrence_sort && list1->occurrence < list2->occurrence
- || hash_sort && list1->hash_value > list2->hash_value
- || key_sort && ACE_OS::strcmp (list1->key, list2->key) >= 0)
- {
- list2->next = merge (list2->next, list1);
- return list2;
- }
- else
- {
- list1->next = merge (list1->next, list2);
- return list1;
- }
-}
-
-// 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)
-{
- if (!a_head || !a_head->next)
- return a_head;
- else
- {
- List_Node *middle = a_head;
- List_Node *temp = a_head->next->next;
-
- while (temp)
- {
- temp = temp->next;
- middle = middle->next;
- if (temp)
- temp = temp->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.
-
-inline int
-Key_List::occurrence (List_Node *ptr)
-{
- int value = 0;
-
- for (char *temp = ptr->keysig; *temp; temp++)
- value += Vectors::occurrences[(int) *temp];
-
- return value;
-}
-
-// Sets the index location for all keysig characters that are now
-// determined.
-
-inline void
-Key_List::determined (List_Node *ptr)
-{
- for (char *temp = ptr->keysig; *temp; temp++)
- Key_List::determined_[(int) *temp] = 1;
-}
-
-// Returns TRUE if PTR's key set is already completely determined.
-
-inline int
-Key_List::already_determined (List_Node *ptr)
-{
- int is_determined = 1;
-
- for (char *temp = ptr->keysig; is_determined && *temp; temp++)
- is_determined = determined_[(int) *temp];
-
- 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....
-
-void
-Key_List::reorder (void)
-{
- List_Node *ptr;
-
- for (ptr = head; ptr; ptr = ptr->next)
- ptr->occurrence = occurrence (ptr);
-
- // Switch to sorting by occurrence.
- hash_sort = 0;
- occurrence_sort = 1;
-
- for (ptr = head = merge_sort (head); ptr->next; ptr = ptr->next)
- {
- determined (ptr);
-
- if (already_determined (ptr->next))
- continue;
- else
- {
- List_Node *trail_ptr = ptr->next;
- List_Node *run_ptr = trail_ptr->next;
-
- for (; run_ptr; run_ptr = trail_ptr->next)
- {
-
- if (already_determined (run_ptr))
- {
- trail_ptr->next = run_ptr->next;
- run_ptr->next = ptr->next;
- ptr = ptr->next = run_ptr;
- }
- else
- trail_ptr = run_ptr;
- }
- }
- }
-}
-
-// 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 (void)
-{
- List_Node *temp;
- for (temp = head; temp->next; temp = temp->next)
- continue;
-
- min_hash_value = head->hash_value;
- max_hash_value = temp->hash_value;
-
- if (!option[ENUM])
- ACE_OS::printf ("\n#define TOTAL_KEYWORDS %d\n#define MIN_WORD_LENGTH %d"
- "\n#define MAX_WORD_LENGTH %d\n#define MIN_HASH_VALUE %d"
- "\n#define MAX_HASH_VALUE %d\n#define HASH_VALUE_RANGE %d"
- "\n#define DUPLICATES %d\n#define WORDLIST_SIZE %d\n\n",
- 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, total_keys + min_hash_value);
- else if (option[GLOBAL])
- ACE_OS::printf ("enum\n{\n"
- " TOTAL_KEYWORDS = %d,\n"
- " MIN_WORD_LENGTH = %d,\n"
- " MAX_WORD_LENGTH = %d,\n"
- " MIN_HASH_VALUE = %d,\n"
- " MAX_HASH_VALUE = %d,\n"
- " HASH_VALUE_RANGE = %d,\n"
- " DUPLICATES = %d\n"
- " WORDLIST_SIZE = %d};\n\n",
- 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, total_keys + min_hash_value);
-}
-
-// 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 (int use_keyword_table)
-{
- if (!option[GLOBAL] && use_keyword_table == 0)
- {
- if (option[LENTABLE] && option[DUP])
- output_keylength_table ();
- if (option[POINTER] && option[TYPE])
- output_keyword_table ();
- }
-
- ACE_Auto_Basic_Array_Ptr<char> safe_comp_buffer;
- char * comp_buffer;
-
- List_Node *curr = head;
- int pointer_and_type_enabled = option[POINTER] && option[TYPE];
- int total_switches = option.total_switches ();
- int switch_size = keyword_list_length () / total_switches;
-
- if (pointer_and_type_enabled)
- {
- // Keep track of the longest string we'll need!
- const char *s = "charmap[*str] == *resword->%s && !ACE_OS::strncasecmp (str + 1, resword->%s + 1, len - 1)";
-
- char * const tmp =
- new char[ACE_OS::strlen (s)
- + 2 * ACE_OS::strlen (option.key_name ()) + 1];
- safe_comp_buffer.reset (tmp);
-
- comp_buffer = safe_comp_buffer.get ();
-
- if (option[COMP])
- ACE_OS::sprintf (comp_buffer, "%s == *resword->%s && !%s (str + 1, resword->%s + 1, len - 1)",
- option[STRCASECMP] ? "charmap[*str]" : "*str", option.key_name (),
- option[STRCASECMP] ? "strncasecmp" : "strncmp", option.key_name ());
- else
- ACE_OS::sprintf (comp_buffer, "%s == *resword->%s && !%s (str + 1, resword->%s + 1)",
- option[STRCASECMP] ? "charmap[*str]" : "*str", option.key_name (),
- option[STRCASECMP] ? "strcasecmp" : "strcmp", option.key_name ());
- }
- else
- {
- if (option[COMP])
- comp_buffer = option[STRCASECMP]
- ? (char *) "charmap[*str] == *resword && !ACE_OS::strncasecmp (str + 1, resword + 1, len - 1)"
- : (char *) "*str == *resword && !ACE_OS::strncmp (str + 1, resword + 1, len - 1)";
- else
- comp_buffer = option[STRCASECMP]
- ? (char *) "charmap[*str] == *resword && !ACE_OS::strncasecmp (str + 1, resword + 1, len - 1)"
- : (char *) "*str == *resword && !ACE_OS::strcmp (str + 1, resword + 1)";
- }
- if (!option[OPTIMIZE])
- ACE_OS::printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n {\n");
- ACE_OS::printf (" unsigned int key = %s (str, len);\n\n", option.hash_name ());
- if (!option[OPTIMIZE])
- ACE_OS::printf (" if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)\n");
-
- ACE_OS::printf (" {\n");
-
- // Properly deal with user's who request multiple switch statements.
-
- while (curr)
- {
- List_Node *temp = curr;
- int lowest_case_value = curr->hash_value;
- int number_of_cases = 0;
-
- // 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)
- while (temp->next && temp->hash_value == temp->next->hash_value)
- temp = temp->next;
-
- if (temp && total_switches != 1)
- ACE_OS::printf (" if (key <= %d)\n {\n", temp->hash_value);
- else
- ACE_OS::printf (" {\n");
-
- // Output each keyword as part of a switch statement indexed by
- // hash value.
-
- if (option[POINTER] || option[DUP] || use_keyword_table)
- {
- int i = 0;
-
- ACE_OS::printf (" %s%s *resword; %s\n\n",
- option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "",
- pointer_and_type_enabled ? struct_tag : "char",
- option[LENTABLE] && !option[DUP] ? "unsigned int key_len;" : "");
- if (total_switches == 1)
- {
- ACE_OS::printf (" switch (key)\n {\n");
- lowest_case_value = 0;
- }
- else
- ACE_OS::printf (" switch (key - %d)\n {\n", lowest_case_value);
-
- for (temp = curr; temp && ++i <= number_of_cases; temp = temp->next)
- {
- ACE_OS::printf (" case %*d:\n",
- Key_List::field_width,
- temp->hash_value - lowest_case_value);
-
- // Handle `static links,' i.e., those that occur during
- // the initial preprocessing.
-
- if (temp->link == 0)
- {
- if (option[DEBUGGING])
- ACE_OS::printf (" /* hash value = %4d, keyword = \"%s\" */\n",
- temp->hash_value,
- temp->key);
- }
- else
- {
- List_Node *links;
-
- for (links = temp; links; links = links->link)
- {
- if (option[DEBUGGING])
- ACE_OS::printf (" /* hash value = %4d, keyword = \"%s\" */\n",
- temp->hash_value,
- links->key);
- if (pointer_and_type_enabled)
- ACE_OS::printf (" resword = &wordlist[%d];\n", links->slot);
- else if (use_keyword_table)
- ACE_OS::printf (" resword = wordlist[%d];\n", links->slot);
- else
- ACE_OS::printf (" resword = \"%s\";\n", links->key);
- ACE_OS::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.
- if (temp->next && temp->hash_value == temp->next->hash_value)
- {
-
- for ( ; temp->next && temp->hash_value == temp->next->hash_value;
- temp = temp->next)
- {
- if (pointer_and_type_enabled)
- ACE_OS::printf (" resword = &wordlist[%d];\n", temp->slot);
- else if (use_keyword_table)
- ACE_OS::printf (" resword = wordlist[%d];", temp->slot);
- else
- ACE_OS::printf (" resword = \"%s\";\n", temp->key);
- ACE_OS::printf (" if (%s) return resword;\n", comp_buffer);
- }
- if (pointer_and_type_enabled)
- ACE_OS::printf (" resword = &wordlist[%d];\n", temp->slot);
- else if (use_keyword_table)
- ACE_OS::printf (" resword = wordlist[%d];", temp->slot);
- else
- ACE_OS::printf (" resword = \"%s\";\n", temp->key);
- ACE_OS::printf (" return %s ? resword : 0;\n", comp_buffer);
- }
- else if (temp->link)
- ACE_OS::printf (" return 0;\n");
- else
- {
- if (pointer_and_type_enabled)
- ACE_OS::printf (" resword = &wordlist[%d];", temp->slot);
- else if (use_keyword_table)
- ACE_OS::printf (" resword = wordlist[%d];", temp->slot);
- else
- ACE_OS::printf (" resword = \"%s\";", temp->key);
- if (option[LENTABLE] && !option[DUP])
- ACE_OS::printf (" key_len = %d;", temp->length);
- ACE_OS::printf (" break;\n");
- }
- }
- ACE_OS::printf (" default: return 0;\n }\n");
- if (option[OPTIMIZE])
- ACE_OS::printf (" return resword;\n");
- else
- {
- ACE_OS::printf (option[LENTABLE] && !option[DUP]
- ? " if (len == key_len && %s)\n return resword;\n"
- : " if (%s)\n return resword;\n", comp_buffer);
- ACE_OS::printf (" return 0;\n");
- }
- ACE_OS::printf (" }\n");
- curr = temp;
- }
- else // Nothing special required here.
- {
- int i = 0;
- ACE_OS::printf (" char *s;\n\n switch (key - %d)\n {\n",
- lowest_case_value);
-
- for (temp = curr; temp && ++i <= number_of_cases; temp = temp->next)
- if (option[LENTABLE])
- ACE_OS::printf (" case %*d: if (len == %d) s = \"%s\"; else return 0; break;\n",
- Key_List::field_width,
- temp->hash_value - lowest_case_value,
- temp->length,
- temp->key);
- else
- ACE_OS::printf (" case %*d: s = \"%s\"; break;\n",
- Key_List::field_width,
- temp->hash_value - lowest_case_value,
- temp->key);
-
- ACE_OS::printf (" default: return 0;\n }\n ");
- if (option[COMP])
- ACE_OS::printf ("return %s == *s && !%s;\n }\n",
- option[STRCASECMP] ? "charmap[*str]" : "*str",
- option[STRCASECMP] ? "strncasecmp (s + 1, str + 1, len - 1)" : "strcmp (s + 1, str + 1)");
- else
- ACE_OS::printf ("return %s == *s && !%s;\n }\n",
- option[STRCASECMP] ? "charmap[*str]" : "*str",
- option[STRCASECMP] ? "strcasecmp (s + 1, str + 1, len - 1)" : "strcmp (s + 1, str + 1)");
- curr = temp;
- }
- }
- ACE_OS::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.''
-
-void
-Key_List::output_keylength_table (void)
-{
- const int max_column = 15;
- int slot = 0;
- int column = 0;
- const char *indent = option[GLOBAL] ? "" : " ";
- List_Node *temp;
-
- if (!option[DUP] && !option[SWITCH])
- {
- ACE_OS::printf ("\n%sstatic %sunsigned %s lengthtable[] =\n%s%s{\n ",
- indent,
- option[CONSTANT] ? "const " : "",
- max_key_len <= ((int) UCHAR_MAX) ? "char" : (max_key_len <= ((int) USHRT_MAX) ? "short" : "long"),
- indent,
- indent);
-
- for (temp = head; temp; temp = temp->next, slot++)
- {
-
- if (slot < temp->hash_value)
- for ( ; slot < temp->hash_value; slot++)
- ACE_OS::printf ("%3d,%s", 0, ++column % (max_column - 1) ? "" : "\n ");
-
- ACE_OS::printf ("%3d,%s", temp->length, ++column % (max_column - 1 ) ? "" : "\n ");
- }
-
- ACE_OS::printf ("\n%s%s};\n",
- indent,
- indent);
- }
-}
-
-// Prints out the array containing the key words for the Gen_Perf hash
-// function.
-
-void
-Key_List::output_keyword_table (void)
-{
- const char *l_brace = *head->rest ? "{" : "";
- const char *r_brace = *head->rest ? "}," : "";
- const char *indent = option[GLOBAL] ? "" : " ";
- int slot = 0;
- List_Node *temp;
-
- int pointer_and_type_enabled = option[POINTER] && option[TYPE];
- ACE_OS::printf ("%sstatic %s%swordlist[] =\n%s%s{\n",
- indent,
- option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "",
- struct_tag,
- indent,
- indent);
-
- // Skip over leading blank entries if there are no duplicates.
-
- if (0 < head->hash_value)
- ACE_OS::printf (" ");
-
-
- int column;
-
- for (column = 1; slot < head->hash_value; column++)
- {
- ACE_OS::printf ("%s\"\",%s%s%s",
- l_brace,
- option.fill_default (),
- r_brace,
- column % 9 ? "" : "\n ");
- slot++;
- }
-
- if (0 < head->hash_value && column % 10)
- ACE_OS::printf ("\n");
-
- // Generate an array of reserved words at appropriate locations.
-
- for (temp = head ; temp; temp = temp->next, slot++)
- {
- temp->slot = slot;
-
- if (!option[SWITCH] && (total_duplicates == 0 || !option[DUP]) && slot < temp->hash_value)
- {
- int column;
-
- ACE_OS::printf (" ");
-
- for (column = 1; slot < temp->hash_value; slot++, column++)
- ACE_OS::printf ("%s\"\",%s%s%s",
- l_brace,
- option.fill_default (),
- r_brace,
- column % 9 ? "" : "\n ");
-
- if (column % 10)
- ACE_OS::printf ("\n");
- else
- {
- ACE_OS::printf ("%s\"%s\", %s%s", l_brace, temp->key, temp->rest, r_brace);
- if (option[DEBUGGING])
- ACE_OS::printf (" /* hash value = %d, slot = %d */",
- temp->hash_value,
- temp->slot);
- putchar ('\n');
- continue;
- }
- }
-
- ACE_OS::printf (" %s\"%s\", %s%s", l_brace, temp->key, temp->rest, r_brace);
- if (option[DEBUGGING])
- ACE_OS::printf (" /* hash value = %d, slot = %d */",
- temp->hash_value,
- temp->slot);
- putchar ('\n');
-
- // Deal with links specially.
- if (temp->link)
- for (List_Node *links = temp->link; links; links = links->link)
- {
- links->slot = ++slot;
- ACE_OS::printf (" %s\"%s\", %s%s", l_brace, links->key, links->rest, r_brace);
- if (option[DEBUGGING])
- ACE_OS::printf (" /* hash value = %d, slot = %d */",
- links->hash_value,
- links->slot);
- putchar ('\n');
- }
-
- }
- ACE_OS::printf ("%s%s};\n\n", indent, indent);
-}
-
-// Generates C code for the binary search algorithm that returns
-// the proper encoding for each key word
-
-int
-Key_List::output_binary_search_function (void)
-{
- ACE_OS::printf ("%s\n", include_src);
-
- // Get prototype for strncmp() and strcmp().
- if (!option[SKIPSTRINGH])
- ACE_OS::printf ("#include \"ace/OS_NS_string.h\"\n");
-
- // Output type declaration now, reference it later on....
- if (option[TYPE] && !option[NOTYPE])
- ACE_OS::printf ("%s;\n",
- array_type_);
-
- output_min_max ();
-
- if (option[STRCASECMP])
- output_strcasecmp ();
-
- // Class definition if -M is *not* enabled.
- if (option[CPLUSPLUS] && !option[SKIPCLASS])
- ACE_OS::printf ("class %s {\npublic:\n"
- " static %s%s%s (const char *str);\n};\n\n",
- option.class_name (),
- option[CONSTANT] ? "const " : "",
- return_type,
- option.function_name ());
-
- // Use the inline keyword to remove function overhead.
- if (option[INLINE])
- ACE_OS::printf ("inline\n");
-
- ACE_OS::printf ("%s%s\n", option[CONSTANT] ? "const " : "", return_type);
- if (option[CPLUSPLUS])
- ACE_OS::printf ("%s::", option.class_name ());
-
- ACE_OS::printf (option[ANSI]
- ? "%s (const char *str)\n{\n"
- : "%s (str)\n char *str;\n{\n",
- option.function_name ());
-
-// Use the switch in place of lookup table.
-
- if (option[SWITCH])
- output_switch ();
-
- // Use the lookup table, in place of switch.
- else
- {
- if (!option[GLOBAL])
- {
- if (option[LENTABLE])
- output_keylength_table ();
- output_keyword_table ();
- }
- }
-
- // Logic to handle the Binary Search.
-
- ACE_OS::printf ("int first = 0, last = 0, middle = 0;\n");
-
- if (option[DUP] && total_duplicates > 0)
- {
- ACE_OS::printf ("%s*base = 0;\n",struct_tag);
- }
-
- ACE_OS::printf ("\nlast = %d;\n",total_keys - 1);
- ACE_OS::printf ("while (last >= first)\n");
- ACE_OS::printf ("\t{\n");
- ACE_OS::printf ("\t middle = (last + first) / 2;\n");
- ACE_OS::printf ("\t if (ACE_OS::strcmp (wordlist[middle].%s, str) == 0)\n break;\n", option.key_name());
- ACE_OS::printf ("\t if (ACE_OS::strcmp (wordlist[middle].%s, str) < 0)\n first = middle + 1;\n", option.key_name());
- ACE_OS::printf ("\t else last = middle - 1;\n");
- ACE_OS::printf ("\t}\n");
- ACE_OS::printf ("if (last < first)\n return 0;\n");
- ACE_OS::printf ("else\n return (&wordlist[middle]);\n}\n");
-
- if (additional_code)
- {
- for (;;)
- {
- int c = getchar ();
-
- if (c == EOF)
- break;
- else
- putchar (c);
- }
- }
-
- ACE_OS::fflush(stdout);
-
- return 0;
-
-}
-
-// Generates C code for the linear search algorithm that returns
-// the proper encoding for each key word
-
-int
-Key_List::output_linear_search_function (void)
-{
- ACE_OS::printf ("%s\n", include_src);
-
- // Get prototype for strncmp() and strcmp().
- if (!option[SKIPSTRINGH])
- ACE_OS::printf ("#include \"ace/OS_NS_string.h\"\n");
-
- // Output type declaration now, reference it later on....
- if (option[TYPE] && !option[NOTYPE])
- ACE_OS::printf ("%s;\n",
- array_type_);
-
- output_min_max ();
-
- if (option[STRCASECMP])
- output_strcasecmp ();
-
- // Class definition if -M is *not* enabled.
- if (option[CPLUSPLUS] && !option[SKIPCLASS])
- ACE_OS::printf ("class %s {\npublic:\n"
- " static %s%s%s (const char *str);\n};\n\n",
- option.class_name (),
- option[CONSTANT] ? "const " : "",
- return_type,
- option.function_name ());
-
- // Use the inline keyword to remove function overhead.
- if (option[INLINE])
- ACE_OS::printf ("inline\n");
-
- ACE_OS::printf ("%s%s\n",
- option[CONSTANT] ? "const " : "",
- return_type);
- if (option[CPLUSPLUS])
- ACE_OS::printf ("%s::", option.class_name ());
-
- ACE_OS::printf (option[ANSI]
- ? "%s (const char *str)\n{\n"
- : "%s (str)\n char *str;\n{\n",
- option.function_name ());
-
- // Use the switch in place of lookup table.
-
- if (option[SWITCH])
- output_switch ();
- // Use the lookup table, in place of switch.
- else
- {
- if (!option[GLOBAL])
- {
- if (option[LENTABLE])
- output_keylength_table ();
- output_keyword_table ();
- }
- }
-
- // Logic to handle the Linear Search.
-
- ACE_OS::printf ("for (int i=0; i<=%d; i++)",total_keys-1);
- ACE_OS::printf ("\t{\n");
- ACE_OS::printf ("\t if (ACE_OS::strcmp (wordlist[i].%s, str) == 0)\n", option.key_name());
- ACE_OS::printf ("\t return &wordlist[i];\n");
- ACE_OS::printf ("\t}\n");
- ACE_OS::printf ("return 0;\n}\n");
-
- if (additional_code)
- {
- for (;;)
- {
- int c = getchar ();
-
- if (c == EOF)
- break;
- else
- putchar (c);
- }
- }
-
- ACE_OS::fflush (stdout);
-
- return 0;
-
-}
-// Generates C code for the hash function that returns the proper
-// encoding for each key word.
-
-void
-Key_List::output_hash_function (void)
-{
- const int max_column = 10;
- int count = max_hash_value;
-
- // Lookup table for converting ASCII to EBCDIC.
- static const int ascii_to_ebcdic[ACE_ASCII_SIZE] =
- {
- 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F,
- 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26,
- 0x18, 0x19, 0x3F, 0x27, 0x22, 0x1D, 0x1E, 0x1F,
-
- 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D,
- 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F,
-
- 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
- 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
- 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6,
- 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D,
-
- 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
- 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
- 0xA7, 0xA8, 0xA9, 0xC0, 0x6A, 0xD0, 0xA1, 0x07};
-
- int ebcdic_to_ascii[ACE_EBCDIC_SIZE];
- int target;
-
- // Calculate maximum number of digits required for MAX_HASH_VALUE.
-
- for (Key_List::field_width = 2;
- (count /= 10) > 0;
- Key_List::field_width++)
- continue;
-
- if (option[INLINE])
- ACE_OS::printf ("inline\n");
-
- if (option[C])
- ACE_OS::printf ("static ");
- ACE_OS::printf ("unsigned int\n");
- if (option[CPLUSPLUS])
- ACE_OS::printf ("%s::", option.class_name ());
-
- ACE_OS::printf (option[ANSI]
- ? "%s (const char *str, unsigned int len)\n{\n"
- : "%s (str, len)\n char *str;\n unsigned int len;\n{\n",
- option.hash_name ());
-
- // Generate the asso_values table.
- ACE_OS::printf (" static %sunsigned %s asso_values[] =\n {",
- option[CONSTANT] ? "const " : "",
- max_hash_value < ((int) UCHAR_MAX) ? "char" : (max_hash_value < ((int) USHRT_MAX) ? "short" : "int"));
-
- ACE_OS::printf ("\n#if defined (ACE_MVS)");
-#if ACE_STANDARD_CHARACTER_SET_SIZE == ACE_EBCDIC_SIZE
- {
- // We are running in EBCDIC environment.
- for (count = 0; count < ACE_EBCDIC_SIZE; ++count)
- {
- if (!(count % max_column))
- ACE_OS::printf ("\n ");
-
- ACE_OS::printf ("%*d,",
- Key_List::field_width,
- Vectors::occurrences[count] ? Vectors::asso_values[count] : max_hash_value + 1);
- }
-
- ACE_OS::printf ("\n#else");
-
- for (count = 0; count < ACE_ASCII_SIZE; ++count)
- {
- if (!(count % max_column))
- ACE_OS::printf ("\n ");
-
- target = ascii_to_ebcdic[count];
- ACE_OS::printf ("%*d,",
- Key_List::field_width,
- Vectors::occurrences[target] ? Vectors::asso_values[target] : max_hash_value + 1);
- }
- }
-# else
- {
- // We are running in ASCII environment.
- for (count = 0; count < ACE_EBCDIC_SIZE; ++count)
- ebcdic_to_ascii[count] = 0;
-
- for (count = 0; count < ACE_ASCII_SIZE; ++count)
- {
- target = ascii_to_ebcdic[count];
- ebcdic_to_ascii[target] = count;
- }
-
- for (count = 0; count < ACE_EBCDIC_SIZE; ++count)
- {
- if (!(count % max_column))
- ACE_OS::printf ("\n ");
-
- target = ebcdic_to_ascii[count];
- ACE_OS::printf ("%*d,",
- Key_List::field_width,
- Vectors::occurrences[target] ? Vectors::asso_values[target] : max_hash_value + 1);
- }
- ACE_OS::printf ("\n#else");
-
- for (count = 0; count < ACE_ASCII_SIZE; ++count)
- {
- if (!(count % max_column))
- ACE_OS::printf ("\n ");
-
- ACE_OS::printf ("%*d,",
- Key_List::field_width,
- Vectors::occurrences[count] ? Vectors::asso_values[count] : max_hash_value + 1);
- }
- }
-#endif /* ACE_STANDARD_CHARACTER_SET_SIZE == ACE_EBCDIC_SIZE */
- ACE_OS::printf ("\n#endif /* ACE_MVS */");
-
- // Optimize special case of ``-k 1,$''
- if (option[DEFAULTCHARS])
- {
- if (option[STRCASECMP])
- ACE_OS::printf ("\n };\n return %sasso_values[(int) charmap[str[len - 1]]] + asso_values[(int) charmap[str[0]]];\n}\n\n",
- option[NOLENGTH] ? "" : "len + ");
- else
- ACE_OS::printf ("\n };\n return %sasso_values[(int) str[len - 1]] + asso_values[(int) str[0]];\n}\n\n",
- option[NOLENGTH] ? "" : "len + ");
- }
- else
- {
- int key_pos;
-
- option.reset ();
-
- // Get first (also highest) key position.
- key_pos = option.get ();
-
- // We can perform additional optimizations here.
- if (!option[ALLCHARS] && key_pos <= min_key_len)
- {
- ACE_OS::printf ("\n };\n return %s", option[NOLENGTH] ? "" : "len + ");
-
- for (; key_pos != WORD_END; )
- {
- ACE_OS::printf (option[STRCASECMP] ? "asso_values[(int) charmap[str[%d]]]" : "asso_values[(int) str[%d]]", key_pos - 1);
- if ((key_pos = option.get ()) != EOS)
- ACE_OS::printf (" + ");
- else
- break;
- }
-
- ACE_OS::printf ("%s;\n}\n\n", key_pos == WORD_END
- ? (option[STRCASECMP] ? "asso_values[(int) charmap[str[len - 1]]]" : "asso_values[(int) str[len - 1]]")
- : "");
- }
-
- // We've got to use the correct, but brute force, technique.
- else
- {
- ACE_OS::printf ("\n };\n unsigned 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.
- if (option[ALLCHARS])
- {
- int i;
-
- // Break these options up for speed (gee, is this misplaced efficiency or what?!
- if (option[STRCASECMP])
-
- for (i = max_key_len; i > 0; i--)
- ACE_OS::printf (" case %d:\n hval += asso_values[(int) charmap[(int) str[%d]]];\n", i, i - 1);
-
- else
-
- for (i = max_key_len; i > 0; i--)
- ACE_OS::printf (" case %d:\n hval += asso_values[(int) str[%d]];\n", i, i - 1);
-
- ACE_OS::printf (" }\n return hval;\n}\n\n");
- }
- else // do the hard part...
- {
- count = key_pos + 1;
-
- do
- {
-
- while (--count > key_pos)
- ACE_OS::printf (" case %d:\n", count);
-
- ACE_OS::printf (option[STRCASECMP]
- ? " case %d:\n hval += asso_values[(int) charmap[(int) str[%d]]];\n"
- : " case %d:\n hval += asso_values[(int) str[%d]];\n",
- key_pos, key_pos - 1);
- }
- while ((key_pos = option.get ()) != EOS && key_pos != WORD_END);
-
- ACE_OS::printf (" }\n return hval%s;\n}\n\n",
- key_pos == WORD_END
- ? (option[STRCASECMP] ? " + asso_values[(int) charmap[(int) str[len - 1]]]" : " + asso_values[(int) str[len - 1]]")
- : "");
- }
- }
- }
-}
-
-int
-Key_List::count_duplicates (List_Node *link,
- const char *type)
-{
- int count = 0;
-
- // Count the number of "static" duplicates for this hash value.
- for (List_Node *ptr = link;
- ptr != 0;
- ptr = ptr->link)
- {
- count++;
-
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "%s linked keyword = %s, slot = %d, hash_value = %d\n",
- type,
- ptr->key,
- ptr->slot,
- ptr->hash_value));
- }
-
- return count;
-}
-
-void
-Key_List::update_lookup_array (int lookup_array[],
- int i1,
- int i2,
- Duplicate_Entry *dup_ptr,
- int value)
-{
- lookup_array[i1] = -dup_ptr->slot;
- lookup_array[i2] = -dup_ptr->count;
- lookup_array[dup_ptr->hash_value] = value;
-}
-
-// Generates the large, sparse table that maps hash values in the
-// smaller, contiguous range of the keyword table.
-
-int
-Key_List::output_lookup_array (void)
-{
- if (total_duplicates > 0)
- {
- const int DEFAULT_VALUE = -1;
-
- Duplicate_Entry *duplicates = 0;
- ACE_NEW_RETURN (duplicates,
- Duplicate_Entry[total_duplicates],
- -1);
-
- int *lookup_array = 0;
- ACE_NEW_RETURN (lookup_array,
- int[max_hash_value + 1],
- -1);
-
- Duplicate_Entry *dup_ptr = duplicates;
- int *lookup_ptr = lookup_array + max_hash_value + 1;
-
- // Initialize the lookup array to the DEFAULT_VALUE (-1).
- while (lookup_ptr > lookup_array)
- *--lookup_ptr = DEFAULT_VALUE;
-
- // Iterate through the keylist and handle the static and dynamic
- // duplicate entries.
- for (List_Node *temp = head; temp; temp = temp->next)
- {
- int hash_value = temp->hash_value;
- // Store the keyword's slot location into the
- // <lookup_array> at the <hash_value>. If this is a
- // non-duplicate, then this value will point directly to the
- // keyword.
- lookup_array[hash_value] = temp->slot;
-
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "keyword = %s, slot = %d, hash_value = %d, lookup_array[hash_value] = %d\n",
- temp->key,
- temp->slot,
- temp->hash_value,
- lookup_array[temp->hash_value]));
-
- if (temp->link == 0 &&
- (temp->next == 0 || hash_value != temp->next->hash_value))
- // This isn't a duplicate. Note that we know this because
- // we sorted the keys by their hash value.
- continue;
- else
- {
- // We'll handle the duplicates here.
- dup_ptr->hash_value = hash_value;
- dup_ptr->slot = temp->slot;
- dup_ptr->count = 1;
-
- // Count the number of "static" duplicates, i.e.,
- // keywords that had the same keysig when the keyfile
- // was first read.
- dup_ptr->count += this->count_duplicates (temp->link,
- "static");
-
- // Count the number of "dynamic" duplicates, i.e.,
- // keywords that ended up with the same hash value as a
- // result of the <asso_values> contents.
- for (;
- temp->next && hash_value == temp->next->hash_value;
- temp = temp->next)
- dup_ptr->count += this->count_duplicates (temp->next,
- "dynamic");
- dup_ptr++;
- }
- }
-
- // Compute the values in the lookup array.
- while (--dup_ptr >= duplicates)
- {
- if (option[DEBUGGING])
- ACE_DEBUG ((LM_DEBUG,
- "dup_ptr[%d]: hash_value = %d, slot = %d, count = %d\n",
- dup_ptr - duplicates,
- dup_ptr->hash_value,
- dup_ptr->slot,
- dup_ptr->count));
- int i;
-
- // Look to the left first.
- for (i = dup_ptr->hash_value; i > 0; i--)
- if (lookup_array[i] == DEFAULT_VALUE && lookup_array[i - 1] == DEFAULT_VALUE)
- {
- this->update_lookup_array (lookup_array,
- i - 1,
- i,
- dup_ptr,
- -(max_hash_value + (dup_ptr->hash_value - i + 1)));
- break;
- }
-
- // If we didn't find it to the left look to the right
- // instead...
- if (i == 0)
- {
- for (i = dup_ptr->hash_value; i < max_hash_value; i++)
- if (lookup_array[i] == DEFAULT_VALUE && lookup_array[i + 1] == DEFAULT_VALUE)
- {
- this->update_lookup_array (lookup_array,
- i,
- i + 1,
- dup_ptr,
- max_hash_value + (i - dup_ptr->hash_value));
- break;
- }
-
- // If this happens, we can't use the output array scheme...
- if (i >= max_hash_value)
- {
- option = SWITCH;
- ACE_DEBUG ((LM_DEBUG,
- "GPERF: Automatically changing to -S1 switch option\n"));
- // Since we've already generated the keyword table
- // we need to use it!
- this->output_switch (1);
- return 1; // 1 indicates that we've changed our mind...
- }
- }
- }
-
- lookup_ptr = lookup_array + max_hash_value + 1;
- int max = INT_MIN;
-
- while (lookup_ptr > lookup_array)
- {
- int val = abs (*--lookup_ptr);
- if (max < val)
- max = val;
- }
-
- const char *indent = option[GLOBAL] ? "" : " ";
-
- ACE_OS::printf ("%sstatic %ssigned %s lookup[] =\n%s%s{\n%s", indent, option[CONSTANT] ? "const " : "",
- max <= SCHAR_MAX ? "char" : (max <= SHRT_MAX ? "short" : "int"),
- indent, indent, option[DEBUGGING] ? "" : " ");
-
- int count = max;
-
- // Calculate maximum number of digits required for LOOKUP_ARRAY_SIZE.
-
- for (Key_List::field_width = 2; (count /= 10) > 0; Key_List::field_width++)
- continue;
-
- const int max_column = 15;
- int column = 0;
-
- for (lookup_ptr = lookup_array;
- lookup_ptr < lookup_array + max_hash_value + 1;
- lookup_ptr++)
- {
- if (option[DEBUGGING])
- ACE_OS::printf (" %*d, /* slot = %d */\n",
- Key_List::field_width,
- *lookup_ptr,
- (int)(lookup_ptr - lookup_array));
- else
- ACE_OS::printf ("%*d, %s",
- Key_List::field_width,
- *lookup_ptr,
- ++column % (max_column - 1) ? "" : "\n ");
- }
- ACE_OS::printf ("%s%s%s};\n\n", option[DEBUGGING] ? "" : "\n", indent, indent);
-
- delete [] duplicates;
- delete [] lookup_array;
- }
- return 0;
-}
-
-// Generates C code to perform the keyword lookup.
-
-void
-Key_List::output_lookup_function (void)
-{
- if (!option[OPTIMIZE])
- ACE_OS::printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n {\n");
- ACE_OS::printf (" unsigned int key = %s (str, len);\n\n", option.hash_name ());
- if (!option[OPTIMIZE])
- ACE_OS::printf (" if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)\n");
- ACE_OS::printf (" {\n");
-
- if (option[DUP] && total_duplicates > 0)
- {
- int pointer_and_type_enabled = option[POINTER] && option[TYPE];
-
- ACE_OS::printf (" int slot = lookup[key];\n\n"
- " if (slot >= 0 && slot < WORDLIST_SIZE)\n");
- if (option[OPTIMIZE])
- ACE_OS::printf (" return %swordlist[slot];\n", option[TYPE] && option[POINTER] ? "&" : "");
- else
- {
- ACE_OS::printf (" {\n"
- " %schar *s = wordlist[slot]", option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "");
- if (array_type_ != Key_List::default_array_type)
- ACE_OS::printf (".%s", option.key_name ());
-
- ACE_OS::printf (";\n\n if (%s%s == *s && !%s)\n return %s;\n }\n",
- option[LENTABLE] ? "len == lengthtable[key]\n && " : "",
- option[STRCASECMP] ? "charmap[*str]" : "*str",
- option[COMP] ? (option[STRCASECMP] ? "strncasecmp (str + 1, s + 1, len - 1)" : "strncmp (str + 1, s + 1, len - 1)")
- : (option[STRCASECMP] ? "strcasecmp (str + 1, s + 1)" : "strcmp (str + 1, s + 1)"),
- option[TYPE] && option[POINTER] ? "&wordlist[slot]" : "s");
- ACE_OS::printf (" else if (slot < 0 && slot >= -MAX_HASH_VALUE)\n"
- " return 0;\n");
- }
- ACE_OS::printf (" else\n {\n"
- " unsigned int offset = key + slot + (slot > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);\n"
- " %s%s*base = &wordlist[-lookup[offset]];\n"
- " %s%s*ptr = base + -lookup[offset + 1];\n\n"
- " while (--ptr >= base)\n ",
- option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "", struct_tag,
- option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "", struct_tag);
- if (array_type_ != Key_List::default_array_type)
- {
- if (option[COMP])
- ACE_OS::printf ("if (%s == *ptr->%s && !%s (str + 1, ptr->%s + 1, len - 1",
- option[STRCASECMP] ? "charmap[*str]" : "*str", option.key_name (),
- option[STRCASECMP] ? "strncasecmp" : "strncmp", option.key_name ());
- else
- ACE_OS::printf ("if (%s == *ptr->%s && !%s (str + 1, ptr->%s + 1",
- option[STRCASECMP] ? "charmap[*str]" : "*str", option.key_name (),
- option[STRCASECMP] ? "strcasecmp" : "strcmp", option.key_name ());
- }
- else
- ACE_OS::printf (option[STRCASECMP] ? "if (charmap[*str] == **ptr && !%s" : "if (*str == **ptr && !%s",
- option[COMP]
- ? (option[STRCASECMP] ? "strncasecmp (str + 1, *ptr + 1, len - 1" : "strncmp (str + 1, *ptr + 1, len - 1")
- : (option[STRCASECMP] ? "strcasecmp (str + 1, *ptr + 1" : "strcmp (str + 1, *ptr + 1"));
- ACE_OS::printf ("))\n return %sptr;"
- "\n }\n }\n %s\n}\n", array_type_ ==
- Key_List::default_array_type ? "*" : "", option[OPTIMIZE] ? "" : "}\n return 0;");
- }
- else
- {
- if (option[OPTIMIZE])
- ACE_OS::printf (" return %swordlist[key]", option[TYPE] && option[POINTER] ? "&" : "");
- else
- {
- int pointer_and_type_enabled = option[POINTER] && option[TYPE];
-
- ACE_OS::printf (" %schar *s = wordlist[key]", option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "");
-
- if (array_type_ != Key_List::default_array_type)
- ACE_OS::printf (".%s", option.key_name ());
-
- ACE_OS::printf (";\n\n if (%s%s == *s && !%s)\n return %s",
- option[LENTABLE] ? "len == lengthtable[key]\n && " : "",
- option[STRCASECMP] ? "charmap[*str]" : "*str",
- option[COMP]
- ? (option[STRCASECMP] ? "strncasecmp (str + 1, s + 1, len - 1)" : "strncmp (str + 1, s + 1, len - 1)")
- : (option[STRCASECMP] ? "strcasecmp (str + 1, s + 1)" : "strcmp (str + 1, s + 1)"),
- option[TYPE] && option[POINTER] ? "&wordlist[key]" : "s");
- }
- ACE_OS::printf (";\n }\n %s\n}\n", option[OPTIMIZE] ? "" : "}\n return 0;");
- }
-}
-
-// Output the table and the functions that map upper case into lower case!
-
-void
-Key_List::output_strcasecmp (void)
-{
- ACE_OS::printf ("%s",
- "/* This array is designed for mapping upper and lower case letter\n"
- " * together for a case independent comparison. The mappings are\n"
- " * based upon ascii character sequences.\n */"
- "static char charmap[] = {\n"
- " '\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\007',\n"
- " '\\010', '\\011', '\\012', '\\013', '\\014', '\\015', '\\016', '\\017',\n"
- " '\\020', '\\021', '\\022', '\\023', '\\024', '\\025', '\\026', '\\027',\n"
- " '\\030', '\\031', '\\032', '\\033', '\\034', '\\035', '\\036', '\\037',\n"
- " '\\040', '\\041', '\\042', '\\043', '\\044', '\\045', '\\046', '\\047',\n"
- " '\\050', '\\051', '\\052', '\\053', '\\054', '\\055', '\\056', '\\057',\n"
- " '\\060', '\\061', '\\062', '\\063', '\\064', '\\065', '\\066', '\\067',\n"
- " '\\070', '\\071', '\\072', '\\073', '\\074', '\\075', '\\076', '\\077',\n"
- " '\\100', '\\141', '\\142', '\\143', '\\144', '\\145', '\\146', '\\147',\n"
- " '\\150', '\\151', '\\152', '\\153', '\\154', '\\155', '\\156', '\\157',\n"
- " '\\160', '\\161', '\\162', '\\163', '\\164', '\\165', '\\166', '\\167',\n"
- " '\\170', '\\171', '\\172', '\\133', '\\134', '\\135', '\\136', '\\137',\n"
- " '\\140', '\\141', '\\142', '\\143', '\\144', '\\145', '\\146', '\\147',\n"
- " '\\150', '\\151', '\\152', '\\153', '\\154', '\\155', '\\156', '\\157',\n"
- " '\\160', '\\161', '\\162', '\\163', '\\164', '\\165', '\\166', '\\167',\n"
- " '\\170', '\\171', '\\172', '\\173', '\\174', '\\175', '\\176', '\\177',\n"
- " '\\200', '\\201', '\\202', '\\203', '\\204', '\\205', '\\206', '\\207',\n"
- " '\\210', '\\211', '\\212', '\\213', '\\214', '\\215', '\\216', '\\217',\n"
- " '\\220', '\\221', '\\222', '\\223', '\\224', '\\225', '\\226', '\\227',\n"
- " '\\230', '\\231', '\\232', '\\233', '\\234', '\\235', '\\236', '\\237',\n"
- " '\\240', '\\241', '\\242', '\\243', '\\244', '\\245', '\\246', '\\247',\n"
- " '\\250', '\\251', '\\252', '\\253', '\\254', '\\255', '\\256', '\\257',\n"
- " '\\260', '\\261', '\\262', '\\263', '\\264', '\\265', '\\266', '\\267',\n"
- " '\\270', '\\271', '\\272', '\\273', '\\274', '\\275', '\\276', '\\277',\n"
- " '\\300', '\\341', '\\342', '\\343', '\\344', '\\345', '\\346', '\\347',\n"
- " '\\350', '\\351', '\\352', '\\353', '\\354', '\\355', '\\356', '\\357',\n"
- " '\\360', '\\361', '\\362', '\\363', '\\364', '\\365', '\\366', '\\367',\n"
- " '\\370', '\\371', '\\372', '\\333', '\\334', '\\335', '\\336', '\\337',\n"
- " '\\340', '\\341', '\\342', '\\343', '\\344', '\\345', '\\346', '\\347',\n"
- " '\\350', '\\351', '\\352', '\\353', '\\354', '\\355', '\\356', '\\357',\n"
- " '\\360', '\\361', '\\362', '\\363', '\\364', '\\365', '\\366', '\\367',\n"
- " '\\370', '\\371', '\\372', '\\373', '\\374', '\\375', '\\376', '\\377',\n};\n\nstatic int\n");
- if (option[COMP])
- {
- ACE_OS::printf ("%s", option[ANSI]
- ? "strncasecmp (char *s1, char *s2, int n)"
- : "strncasecmp (s1, s2, n)\n char *s1, *s2;\n int n;");
- ACE_OS::printf ("\n{\n char *cm = charmap;\n\n while (--n >= 0 && cm[*s1] == cm[*s2++])\n"
- " if (*s1++ == '\\0')\n return 0;\n"
- "\n return n < 0 ? 0 : cm[*s1] - cm[*--s2];\n}\n\n");
- }
- else
- {
- ACE_OS::printf ("%s", option[ANSI]
- ? "strcasecmp (char *s1, char *s2)"
- : "strcasecmp (s1, s2)\n char *s1, *s2;");
- ACE_OS::printf ("\n{\n char *cm = charmap;\n\n while (cm[*s1] == cm[*s2++])\n"
- " if (*s1++ == '\\0')\n return 0;\n"
- "\n return cm[*s1] - cm[*--s2];\n}\n\n");
- }
-}
-
-// Generates the hash function and the key word recognizer function
-// based upon the user's Options.
-
-int
-Key_List::output (void)
-{
- if (option[BINARYSEARCH])
- // Generate code binary search.
- this->output_binary_search_function ();
- else if (option[LINEARSEARCH])
- // Generate code for linear search.
- this->output_linear_search_function ();
- else
- {
- // Generate the usual GPERF things.
- ACE_OS::printf ("%s\n", include_src);
-
- // Get prototype for strncmp() and strcmp().
- if (!option[SKIPSTRINGH])
- ACE_OS::printf ("#include \"ace/OS_NS_string.h\"\n");
-
- // Output type declaration now, reference it later on....
- if (option[TYPE] && !option[NOTYPE])
- ACE_OS::printf ("%s;\n",
- array_type_);
-
- output_min_max ();
-
- if (option[STRCASECMP])
- output_strcasecmp ();
-
- // Class definition if -M is *not* enabled.
- if (option[CPLUSPLUS] && !option[SKIPCLASS])
- ACE_OS::printf ("class %s\n{\nprivate:\n"
- " static unsigned int %s (const char *str, unsigned int len);\npublic:\n"
- " static %s%s%s (const char *str, unsigned int len);\n};\n\n",
- option.class_name (),
- option.hash_name (),
- option[CONSTANT] ? "const " : "",
- return_type,
- option.function_name ());
-
- output_hash_function ();
-
- if (option[GLOBAL])
- if (option[SWITCH])
- {
- if (option[LENTABLE] && option[DUP])
- output_keylength_table ();
- if (option[POINTER] && option[TYPE])
- output_keyword_table ();
- }
- else
- {
- if (option[LENTABLE])
- output_keylength_table ();
- output_keyword_table ();
- if (output_lookup_array () == -1)
- ACE_ERROR_RETURN ((LM_DEBUG,
- "%p\n",
- "output_lookup_array"),
- -1);
- }
-
- // Use the inline keyword to remove function overhead.
- if (option[INLINE])
- ACE_OS::printf ("inline\n");
-
- int pointer_and_type_enabled = option[POINTER] && option[TYPE];
-
- ACE_OS::printf ("%s%s\n",
- option[CONSTANT] || pointer_and_type_enabled == 0 ? "const " : "",
- return_type);
- if (option[CPLUSPLUS])
- ACE_OS::printf ("%s::", option.class_name ());
-
- ACE_OS::printf (option[ANSI]
- ? "%s (const char *str, unsigned int len)\n{\n"
- : "%s (str, len)\n char *str;\n unsigned int len;\n{\n",
- option.function_name ());
-
- if (option[ENUM] && !option[GLOBAL])
- ACE_OS::printf (" enum\n {\n"
- " TOTAL_KEYWORDS = %d,\n"
- " MIN_WORD_LENGTH = %d,\n"
- " MAX_WORD_LENGTH = %d,\n"
- " MIN_HASH_VALUE = %d,\n"
- " MAX_HASH_VALUE = %d,\n"
- " HASH_VALUE_RANGE = %d,\n"
- " DUPLICATES = %d,\n"
- " WORDLIST_SIZE = %d\n };\n\n",
- 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, total_keys + min_hash_value);
- // Use the switch in place of lookup table.
- if (option[SWITCH])
- output_switch ();
- // Use the lookup table, in place of switch.
- else
- {
- if (!option[GLOBAL])
- {
- if (option[LENTABLE])
- output_keylength_table ();
- output_keyword_table ();
- }
- if (!option[GLOBAL])
- {
- switch (output_lookup_array ())
- {
- case -1:
- ACE_ERROR_RETURN ((LM_DEBUG,
- "%p\n",
- "output_lookup_array"),
- -1);
- /* NOTREACHED */
- case 0:
- output_lookup_function ();
- break;
- /* NOTREACHED */
- default:
- break;
- /* NOTREACHED */
- }
- }
- else
- output_lookup_function ();
- }
-
- if (additional_code)
- {
- for (;;)
- {
- int c = getchar ();
-
- if (c == EOF)
- break;
- else
- putchar (c);
- }
- }
- ACE_OS::fflush (stdout);
- }
- return 0;
- }
-
-// Sorts the keys by hash value.
-
-void
-Key_List::sort (void)
-{
- // By default, we sort via hashing.
- hash_sort = 1;
- occurrence_sort = 0;
-
- this->head = merge_sort (this->head);
-}
-
-// Sorts the keys by normal strcmp.
-void
-Key_List::string_sort (void)
-{
-
- // Flatten the equivalence class list to a linear list.
-
- List_Node *ptr;
- for(ptr=head;ptr;ptr=ptr->next)
- {
- List_Node *curr;
- if(ptr->link)
- {
- List_Node *last_node = 0;
-
- for(curr = ptr->link; curr; curr = curr->link)
- {
- // Chnage the link to next pointer.
- curr->next = curr->link;
-
- // Save the pointer for the last node.
- if (curr->link == 0)
- last_node = curr;
- }
-
- // Set the pointers, correctly.
- last_node->next = ptr->next;
- ptr->next = ptr->link;
- ptr = last_node;
- }
- }
-
- // Set all links to Null.
-
- for(ptr=head;ptr;ptr=ptr->next)
- {
- ptr->link = 0;
- }
-
- // Set the sorting options.
-
- key_sort = 1;
- hash_sort = 0;
- occurrence_sort = 0;
-
- // Sort.
-
- this->head = merge_sort (head);
- key_sort = 0;
-}
-
-
-// Dumps the key list to stderr stream.
-
-void
-Key_List::dump (void)
-{
- ACE_DEBUG ((LM_DEBUG,
- "\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));
-
- u_int keysig_width = option.max_keysig_size () > ACE_OS::strlen ("keysig")
- ? option.max_keysig_size ()
- : static_cast<u_int> (ACE_OS::strlen ("keysig"));
-
- size_t key_length = this->max_key_length ();
- size_t keyword_width = key_length > ACE_OS::strlen ("keysig")
- ? key_length
- : ACE_OS::strlen ("keysig");
-
- ACE_DEBUG ((LM_DEBUG,
- "\nList contents are:\n(hash value, key length, slot, %*s, %*s, duplicates):\n",
- keysig_width,
- "keysig",
- keyword_width,
- "keyword"));
-
- for (List_Node *ptr = head; ptr; ptr = ptr->next)
- {
- ACE_DEBUG ((LM_DEBUG,
- "%11d,%11d,%6d, %*s, %*s",
- ptr->hash_value,
- ptr->length,
- ptr->slot,
- keysig_width,
- ptr->keysig,
- keyword_width,
- ptr->key));
-
- List_Node *dup = ptr->link;
- if (dup)
- {
- for (;
- dup != 0;
- dup = dup->link)
- ACE_DEBUG ((LM_DEBUG,
- " %s",
- dup->key));
- }
- ACE_DEBUG ((LM_DEBUG,
- "\n"));
- }
- ACE_DEBUG ((LM_DEBUG,
- "End dumping list.\n\n"));
-}
-
-// Simple-minded constructor action here...
-
-Key_List::Key_List (void)
- : head (0),
- total_duplicates (0),
- array_type_ ((char *) Key_List::default_array_type),
- return_type ((char *) Key_List::default_return_type),
- struct_tag ((char *) Key_List::default_array_type),
- max_key_len (INT_MIN),
- min_key_len (INT_MAX),
- key_sort (0),
- additional_code (0),
- total_keys (1)
-{
-}
-
-// Returns the length of entire key list.
-
-int
-Key_List::keyword_list_length (void)
-{
- return list_len;
-}
-
-// Returns length of longest key read.
-
-int
-Key_List::max_key_length (void)
-{
- return max_key_len;
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Key_List.h b/ACE/apps/gperf/src/Key_List.h
deleted file mode 100644
index 34f8e2c05bf..00000000000
--- a/ACE/apps/gperf/src/Key_List.h
+++ /dev/null
@@ -1,173 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef KEY_LIST_H
-#define KEY_LIST_H
-
-#include "Options.h"
-#include "List_Node.h"
-#include "Vectors.h"
-
-#if defined (ACE_HAS_GPERF)
-
-class Duplicate_Entry
-{
- // = TITLE
- // Describes a duplicate entry.
- //
- // = DESCRIPTION
- // This is used for generating code by the <Key_List>.
-public:
- int hash_value;
- // Hash value for this particular duplicate set.
-
- int slot;
- // Slot into the main keyword storage array.
-
- int count;
- // Number of consecutive duplicates at this slot.
-};
-
-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 string_sort (void);
- int read_keys (void);
- int output (void);
-
- List_Node *head;
- // Points to the head of the linked list.
-
- int total_duplicates;
- // Total number of duplicate hash values.
-
-private:
- // = Make hash table 10 times larger than # of keyword entries.
- enum
- {
- TABLE_MULTIPLE = 10
- };
-
- static int occurrence (List_Node *ptr);
- static int already_determined (List_Node *ptr);
- static void determined (List_Node *ptr);
-
- // @@ 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 (int use_keyword_table = 0);
- void output_keyword_table (void);
- void output_keylength_table (void);
- void output_hash_function (void);
- void output_lookup_function (void);
- int output_binary_search_function(void);
- int output_linear_search_function (void);
- int output_lookup_array (void);
- void output_strcasecmp (void);
- int output_types (void);
- void dump (void);
- char *array_type (void);
- char *save_include_src (void);
- char *special_input (char delimiter);
- List_Node *merge (List_Node *list1, List_Node *list2);
- List_Node *merge_sort (List_Node *head);
- int count_duplicates (List_Node *link, const char *type);
- void update_lookup_array (int lookup_array[],
- int i1,
- int i2,
- Duplicate_Entry *dup_ptr,
- int value);
- char *array_type_;
- // Pointer to the type for word list.
-
- char *return_type;
- // Pointer to return type for lookup function.
-
- char *struct_tag;
- // Shorthand for user-defined struct tag type.
-
- char *include_src;
- // C source code to be included verbatim.
-
- int max_key_len;
- // Maximum length of the longest keyword.
-
- int min_key_len;
- // Minimum length of the shortest keyword.
-
- int min_hash_value;
- // Minimum hash value for all keywords.
-
- int max_hash_value;
- // Maximum hash value for all keywords.
-
- int occurrence_sort;
- // True if sorting by occurrence.
-
- int hash_sort;
- // True if sorting by hash value.
-
- int key_sort;
- // True if sorting by key value.
-
- int additional_code;
- // True if any additional C code is included.
-
- int list_len;
- // Length of head's Key_List, not counting duplicates.
-
- int total_keys;
- // Total number of keys, counting duplicates.
-
- static const char *const default_array_type;
- // Default type for generated code.
-
- static const char *const default_return_type;
- // in_word_set return type, by default.
-
- static int field_width;
- // How wide the printed field width must be to contain the maximum
- // hash value.
-
- static int determined_[ACE_STANDARD_CHARACTER_SET_SIZE];
- // Sets the slot location for all keysig characters that are now
- // determined.
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* KEY_LIST_H */
diff --git a/ACE/apps/gperf/src/List_Node.cpp b/ACE/apps/gperf/src/List_Node.cpp
deleted file mode 100644
index 80f4e96be30..00000000000
--- a/ACE/apps/gperf/src/List_Node.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "List_Node.h"
-
-ACE_RCSID(src, List_Node, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "Vectors.h"
-#include "ace/OS_NS_ctype.h"
-
-// Sorts the key set alphabetically to speed up subsequent operation
-// Uses insertion sort since the set is probably quite small.
-
-inline void
-List_Node::sort (char *base, int len)
-{
- int i, j;
-
- for (i = 0, j = len - 1; i < j; i++)
- {
- char curr, tmp;
-
- for (curr = static_cast<char> (i + 1), tmp = base[curr];
- curr > 0 && tmp < base[curr-1];
- curr--)
- base[curr] = base[curr - 1];
-
- base[curr] = tmp;
-
- }
-}
-
-// 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)
- : link (0),
- next (0),
- key (k),
- rest (option[TYPE] ? k + len + 1 : const_cast<char*> ("")),
- length (len),
- slot (0)
-{
- char *ptr = new char[(option[ALLCHARS] ? len : option.max_keysig_size ()) + 1];
- keysig = ptr;
- k[len] = '\0'; // Null terminate KEY to separate it from REST.
-
- // Lower case if STRCASECMP option is enabled.
- if (option[STRCASECMP])
- for (char *p = k; *p; p++)
- if (ACE_OS::ace_isupper (*p))
- *p = static_cast<char> (ACE_OS::ace_tolower (*p));
-
- if (option[ALLCHARS]) // Use all the character position in the KEY.
- for (; *k; k++, ptr++)
- {
- *ptr = *k;
- int i = (int) *ptr;
- ++Vectors::occurrences[i];
- }
- else
- {
- // Only use those character positions specified by the user.
-
- option.reset ();
-
- // Iterate thru the list of key_positions, initializing
- // occurrences table and keysig (via char * pointer ptr).
-
- for (int i; (i = option.get ()) != EOS; )
- {
- 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.
- *ptr = key[i - 1];
- else // Out of range of KEY length, so we'll just skip it.
- continue;
- ++Vectors::occurrences[(int) *ptr++];
- }
-
- // Didn't get any hits and user doesn't want to consider the
- // keylength, so there are essentially no usable hash positions!
- if (ptr == keysig && option[NOLENGTH])
- ACE_ERROR ((LM_ERROR,
- "Can't hash keyword %s with chosen key positions.\n%a",
- key,
- 1));
- }
- // Terminate this string.
- *ptr = '\0';
-
- // Sort the KEYSIG items alphabetically.
- sort (keysig, ptr - keysig);
-}
-
-List_Node::~List_Node (void)
-{
- delete [] this->key;
- delete [] this->keysig;
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/List_Node.h b/ACE/apps/gperf/src/List_Node.h
deleted file mode 100644
index ebe9bd57a99..00000000000
--- a/ACE/apps/gperf/src/List_Node.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef LIST_NODE_H
-#define LIST_NODE_H
-
-#include "ace/config-all.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "Options.h"
-
-#if defined (ACE_HAS_GPERF)
-class List_Node
-{
- // = TITLE
- // Data and function members for defining values and operations of
- // a list node.
-public:
- // = Initialization and termination methods.
- List_Node (char *key, int len);
- // Constructor.
-
- ~List_Node (void);
- // Destructor.
-
- static void sort (char *base, int len);
-
- List_Node *link;
- // TRUE if key has an identical KEY_SET as another key.
-
- List_Node *next;
- // Points to next element on the list.
-
- char *key;
- // Each keyword string stored here.
-
- char *rest;
- // Additional information for building hash function.
-
- char *keysig;
- // Set of characters to hash, specified by user.
-
- int length;
- // Length of the key.
-
- int hash_value;
- // Hash value for the key.
-
- int occurrence;
- // A metric for frequency of key set occurrences.
-
- int slot;
- // Position of this node relative to other nodes.
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* LIST_NODE_H */
diff --git a/ACE/apps/gperf/src/Makefile.am b/ACE/apps/gperf/src/Makefile.am
deleted file mode 100644
index fedfd8649ac..00000000000
--- a/ACE/apps/gperf/src/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-## Process this file with automake to create Makefile.in
-##
-## $Id$
-##
-## This file was generated by MPC. Any changes made directly to
-## this file will be lost the next time it is generated.
-##
-## MPC Command:
-## ./bin/mwc.pl -type automake -noreldefs ACE.mwc
-
-ACE_BUILDDIR = $(top_builddir)
-ACE_ROOT = $(top_srcdir)
-
-
-## Makefile.gperf.am
-
-if !BUILD_USES_WCHAR
-
-bin_PROGRAMS = gperf
-
-gperf_CPPFLAGS = \
- -I$(ACE_ROOT) \
- -I$(ACE_BUILDDIR)
-
-gperf_SOURCES = \
- Bool_Array.cpp \
- Gen_Perf.cpp \
- Hash_Table.cpp \
- Iterator.cpp \
- Key_List.cpp \
- List_Node.cpp \
- Options.cpp \
- Vectors.cpp \
- Version.cpp \
- gperf.cpp \
- Bool_Array.h \
- Gen_Perf.h \
- Hash_Table.h \
- Iterator.h \
- Key_List.h \
- List_Node.h \
- Options.h \
- Vectors.h
-
-gperf_LDADD = \
- $(ACE_BUILDDIR)/ace/libACE.la
-
-endif !BUILD_USES_WCHAR
-
-## Clean up template repositories, etc.
-clean-local:
- -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
- -rm -f gcctemp.c gcctemp so_locations *.ics
- -rm -rf cxx_repository ptrepository ti_files
- -rm -rf templateregistry ir.out
- -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/apps/gperf/src/Options.cpp b/ACE/apps/gperf/src/Options.cpp
deleted file mode 100644
index b6ef8e4a95e..00000000000
--- a/ACE/apps/gperf/src/Options.cpp
+++ /dev/null
@@ -1,873 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Handles parsing the Options provided to the user.
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Options.h"
-
-ACE_RCSID(src, Options, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "ace/Get_Opt.h"
-#include "Iterator.h"
-#include "ace/OS_NS_stdio.h"
-#include "ace/OS_NS_string.h"
-#include "ace/OS_NS_stdlib.h"
-
-// Global option coordinator for the entire program.
-Options option;
-
-// Current program version.
-extern const char *version_string;
-
-// Size to jump on a collision.
-static const int DEFAULT_JUMP_VALUE = 5;
-
-// Default name for generated lookup function.
-static const char *const DEFAULT_NAME = "in_word_set";
-
-// Default filler for keyword table.
-static const char *const DEFAULT_FILL = "";
-
-// Default name for the key component.
-static const char *const DEFAULT_KEY = "name";
-
-// Default name for the generated class.
-static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
-
-// Default name for generated hash function.
-static const char *const DEFAULT_HASH_NAME = "hash";
-
-// Default delimiters that separate keywords from their attributes.
-static const char *const DEFAULT_DELIMITERS = ",\n";
-
-int Options::option_word_;
-int Options::total_switches_;
-u_int Options::total_keysig_size_;
-int Options::size_;
-int Options::key_pos_;
-int Options::jump_;
-int Options::initial_asso_value_;
-int Options::argc_;
-char **Options::argv_;
-int Options::iterations_;
-const char *Options::function_name_;
-const char *Options::fill_default_;
-const char *Options::key_name_;
-const char *Options::class_name_;
-const char *Options::hash_name_;
-const char *Options::delimiters_;
-char Options::key_positions_[MAX_KEY_POS];
-
-// Prints program usage to standard error stream.
-
-void
-Options::usage (void)
-{
- ACE_ERROR ((LM_ERROR,
- "Usage: %n [-abBcCdDef[num]gGhH<hashname>i<init>IjJ"
- "k<keys>K<keyname>lL<language>mMnN<function name>o"
- "Oprs<size>S<switches>tTvVZ<class name>].\n"
- "(type %n -h for help)\n"));
-}
-
-// Output command-line Options.
-
-void
-Options::print_options (void)
-{
- int i;
-
- ACE_OS::printf ("/* Command-line: ");
-
- for (i = 0; i < argc_; i++)
- ACE_OS::printf ("%s ",
- argv_[i]);
-
- ACE_OS::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.
-
-int
-Options::key_sort (char *base, int len)
-{
- int i, j;
-
- for (i = 0, j = len - 1; i < j; i++)
- {
- 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!!!
- return 0;
-
- base[curr] = static_cast<char> (tmp);
- }
-
- return 1;
-}
-
-// 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;
- fill_default_ = DEFAULT_FILL;
- 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.
-
-Options::~Options (void)
-{
- if (ACE_BIT_ENABLED (option_word_, DEBUGGING))
- {
- char *ptr;
-
- ACE_OS::fprintf (stderr,
- "\ndumping Options:"
- "\nDEBUGGING is...: %s"
- "\nORDER is.......: %s"
- "\nANSI is........: %s"
- "\nTYPE is........: %s"
- "\nINLINE 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"
- "\nCONSTANT is....: %s"
- "\nCPLUSPLUS is...: %s"
- "\nC is...........: %s"
- "\nENUM is........: %s"
- "\nSTRCASECMP is..: %s"
- "\nOPTIMIZE is....: %s"
- "\nLINEARSEARCH is: %s"
- "\nBINARYSEARCH is: %s"
- "\niterations = %d"
- "\nlookup function name = %s"
- "\nfill default = %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_, DEBUGGING) ? "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_, INLINE) ? "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_, CONSTANT) ? "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",
- ACE_BIT_ENABLED (option_word_, LINEARSEARCH) ? "enabled" : "disabled",
- ACE_BIT_ENABLED (option_word_, BINARYSEARCH) ? "enabled" : "disabled",
- iterations_,
- function_name_,
- fill_default_,
- 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)
- ACE_OS::fprintf (stderr, "$\n");
- else
- ACE_OS::fprintf (stderr, "%d\n", *ptr);
-
- ACE_OS::fprintf (stderr, "finished dumping Options\n");
- }
-}
-
-// Parses the command line Options and sets appropriate flags in
-// option_word_.
-
-int
-Options::parse_args (int argc, char *argv[])
-{
- if (ACE_LOG_MSG->open (argv[0]) == -1)
- return -1;
-
- //FUZZ: disable check_for_lack_ACE_OS
- ACE_Get_Opt getopt (argc, argv, "abBcCdDe:Ef:F:gGhH:i:IJj:k:K:lL:mMnN:oOprs:S:tTvVZ:");
- //FUZZ: enable check_for_lack_ACE_OS
-
- int option_char;
-
- argc_ = argc;
- argv_ = argv;
-
- while ((option_char = getopt ()) != -1)
- {
- switch (option_char)
- {
- // Generated coded uses the ANSI prototype format.
- case 'a':
- {
- ACE_SET_BITS (option_word_, ANSI);
- break;
- }
- // Generate code for Linear Search.
- case 'b':
- {
- ACE_SET_BITS (option_word_, LINEARSEARCH);
- break;
- }
- // Generate code for Binary Search.
- case 'B':
- {
- ACE_SET_BITS (option_word_, BINARYSEARCH);
- break;
- }
- // Generate strncmp rather than strcmp.
- case 'c':
- {
- ACE_SET_BITS (option_word_, COMP);
- break;
- }
- // Make the generated tables readonly (const).
- case 'C':
- {
- ACE_SET_BITS (option_word_, CONSTANT);
- break;
- }
- // Enable debugging option.
- case 'd':
- {
- ACE_SET_BITS (option_word_, DEBUGGING);
- ACE_ERROR ((LM_ERROR,
- "Starting program %n, version %s, with debugging on.\n",
- version_string));
- break;
- }
- // Enable duplicate option.
- case 'D':
- {
- ACE_SET_BITS (option_word_, DUP);
- break;
- }
- // Allows user to provide keyword/attribute separator
- case 'e':
- {
- delimiters_ = getopt.opt_arg ();
- break;
- }
- case 'E':
- {
- ACE_SET_BITS (option_word_, ENUM);
- break;
- }
- // Generate the hash table ``fast.''
- case 'f':
- {
- ACE_SET_BITS (option_word_, FAST);
- iterations_ = ACE_OS::atoi (getopt.opt_arg ());
- if (iterations_ < 0)
- {
- ACE_ERROR ((LM_ERROR, "iterations value must not be negative, assuming 0\n"));
- iterations_ = 0;
- }
- break;
- }
- // Use the ``inline'' keyword for generated sub-routines.
- case 'g':
- {
- ACE_SET_BITS (option_word_, INLINE);
- break;
- }
- // Make the keyword table a global variable.
- case 'G':
- {
- ACE_SET_BITS (option_word_, GLOBAL);
- break;
- }
- // Displays a list of helpful Options to the user.
- case 'h':
- {
- ACE_OS::fprintf (stderr,
- "-a\tGenerate ANSI standard C output code, i.e., function prototypes.\n"
- "-b\tGenerate code for Linear Search.\n"
- "-B\tGenerate code for Binary Search.\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\n"
- "\terror).\n"
- "-D\tHandle keywords that hash to duplicate values. This is useful\n"
- "\tfor certain highly redundant keyword sets.\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"
- "-F\tProvided expression will be used to assign default values in keyword\n"
- "\ttable, i.e., the fill value. Default is \"\".\n"
- "-g\tMake generated routines use ``inline'' to remove function overhead.\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 message.\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"
- "-J\tSkips '#include \"ace/OS_NS_string.h\"' part in the output.\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\n"
- "\tstructure.\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.\n"
- "\tLanguages handled are currently C++ and C. The default is C.\n"
- "-m\tAvoids the warning about identical hash values. This is valid\n"
- "\tonly if the -D option is enabled.\n"
- "-M\tSkips class definition in the output. This is valid only in C++ mode.\n"
- "-n\tDo not include the length of the keyword when computing the hash\n"
- "\tfunction.\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\n"
- "\tkeywords are 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\n"
- "\tassociated value range should be, in relationship to the number of\n"
- "\tkeys, e.g. a value of 3 means ``allow the maximum associated value\n"
- "\tto be about 3 times larger than the number of input keys.''\n"
- "\tConversely, a value of -3 means ``make the maximum associated\n"
- "\tvalue about 3 times smaller than the number of input keys. A\n"
- "\tlarger table should decrease the time required for an unsuccessful\n"
- "\tsearch, at 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\n"
- "\tof 2 generates 2 tables with 1/2 the elements in each table, etc.\n"
- "\tThis is useful since many C compilers cannot correctly generate code\n"
- "\tfor large 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 and exits with a value of 0\n"
- "-V\tExits silently with a value of 0.\n"
- "-Z\tAllow user to specify name of generated C++ class. Default\n"
- "\tname is `Perfect_Hash.'\n",
- DEFAULT_JUMP_VALUE,
- MAX_KEY_POS - 1);
- Options::usage ();
- return -1;
- }
- // Sets the name for the hash function.
- case 'H':
- {
- hash_name_ = getopt.opt_arg ();
- break;
- }
- // Sets the initial value for the associated values array.
- case 'i':
- {
- initial_asso_value_ = ACE_OS::atoi (getopt.opt_arg ());
- if (initial_asso_value_ < 0)
- ACE_ERROR ((LM_ERROR,
- "Initial value %d should be non-zero, ignoring and continuing.\n",
- initial_asso_value_));
- if (option[RANDOM])
- ACE_ERROR ((LM_ERROR,
- "warning, -r option superceeds -i, ignoring -i option and continuing\n"));
- break;
- }
- case 'I':
- {
- ACE_SET_BITS (option_word_, STRCASECMP);
- break;
- }
- // Sets the jump value, must be odd for later algorithms.
- case 'j':
- {
- jump_ = ACE_OS::atoi (getopt.opt_arg ());
- if (jump_ < 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Jump value %d must be a positive number.\n%r",
- jump_,
- &Options::usage),
- -1);
- else if (jump_ && ACE_EVEN (jump_))
- ACE_ERROR ((LM_ERROR,
- "Jump value %d should be odd, adding 1 and continuing...\n",
- jump_++));
- break;
- }
- // Skip including the header file ace/OS_NS_string.h.
- case 'J':
- {
- ACE_SET_BITS (option_word_, SKIPSTRINGH);
- break;
- }
- // Sets key positions used for hash function.
- case 'k':
- {
- const int BAD_VALUE = -1;
- int value;
- Iterator expand (getopt.opt_arg (),
- 1,
- MAX_KEY_POS - 1,
- WORD_END,
- BAD_VALUE,
- EOS);
-
- // Use all the characters for hashing!!!!
- if (*getopt.opt_arg () == '*')
- option_word_ = (option_word_ & ~DEFAULTCHARS) | ALLCHARS;
- else
- {
- char *l_key_pos;
-
- for (l_key_pos = key_positions_;
- (value = expand ()) != EOS;
- l_key_pos++)
- if (value == BAD_VALUE)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Illegal key value or range, use 1,2,3-%d,'$' or '*'.\n%r",
- MAX_KEY_POS - 1,
- usage),
- -1);
- else
- *l_key_pos = static_cast<char> (value);
-
- *l_key_pos = EOS;
-
- total_keysig_size_ = (l_key_pos - key_positions_);
- if (total_keysig_size_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "No keys selected.\n%r",
- &Options::usage),
- -1);
- else if (key_sort (key_positions_, total_keysig_size_) == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Duplicate keys selected\n%r",
- &Options::usage),
- -1);
- if (total_keysig_size_ != 2
- || (key_positions_[0] != 1
- || key_positions_[1] != WORD_END))
- ACE_CLR_BITS (option_word_, DEFAULTCHARS);
- }
- break;
- }
- // Make this the keyname for the keyword component field.
- case 'K':
- {
- key_name_ = getopt.opt_arg ();
- break;
- }
- // Create length table to avoid extra string compares.
- case 'l':
- {
- ACE_SET_BITS (option_word_, LENTABLE);
- break;
- }
- // Deal with different generated languages.
- case 'L':
- {
- option_word_ &= ~C;
- if (!ACE_OS::strcmp (getopt.opt_arg (), "C++"))
- ACE_SET_BITS (option_word_, (CPLUSPLUS | ANSI));
- else if (!ACE_OS::strcmp (getopt.opt_arg (), "C"))
- ACE_SET_BITS (option_word_, C);
- else
- {
- ACE_ERROR ((LM_ERROR,
- "unsupported language option %s, defaulting to C\n",
- getopt.opt_arg ()));
- ACE_SET_BITS (option_word_, C);
- }
- break;
- }
- // Don't print the warnings.
- case 'm':
- {
- ACE_SET_BITS (option_word_, MUTE);
- break;
- }
- // Skip the class definition while in C++ mode.
- case 'M':
- {
- ACE_SET_BITS (option_word_, SKIPCLASS);
- break;
- }
- // Don't include the length when computing hash function.
- case 'n':
- {
- ACE_SET_BITS (option_word_, NOLENGTH);
- break;
- }
- // Make generated lookup function name be.opt_arg ()
- case 'N':
- {
- function_name_ = getopt.opt_arg ();
- break;
- }
- // Make fill_default be.opt_arg ()
- case 'F':
- {
- fill_default_ = getopt.opt_arg ();
- break;
- }
- // Order input by frequency of key set occurrence.
- case 'o':
- {
- ACE_SET_BITS (option_word_, ORDER);
- break;
- }
- case 'O':
- {
- ACE_SET_BITS (option_word_, OPTIMIZE);
- break;
- }
- // Generated lookup function now a pointer instead of int.
- case 'p':
- {
- ACE_SET_BITS (option_word_, POINTER);
- break;
- }
- // Utilize randomness to initialize the associated values
- // table.
- case 'r':
- {
- ACE_SET_BITS (option_word_, RANDOM);
- if (initial_asso_value_ != 0)
- ACE_ERROR ((LM_ERROR,
- "warning, -r option superceeds -i, disabling -i option and continuing\n"));
- break;
- }
- // Range of associated values, determines size of final table.
- case 's':
- {
- size_ = ACE_OS::atoi (getopt.opt_arg ());
- if (abs (size_) > 50)
- ACE_ERROR ((LM_ERROR,
- "%d is excessive, did you really mean this?! (type %n -h for help)\n",
- size_));
- break;
- }
- // Generate switch statement output, rather than lookup table.
- case 'S':
- {
- ACE_SET_BITS (option_word_, SWITCH);
- total_switches_ = ACE_OS::atoi (getopt.opt_arg ());
- if (total_switches_ <= 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "number of switches %s must be a positive number\n%r",
- getopt.opt_arg (),
- &Options::usage),
- -1);
- break;
- }
- // Enable the TYPE mode, allowing arbitrary user structures.
- case 't':
- {
- ACE_SET_BITS (option_word_, TYPE);
- break;
- }
- // Don't print structure definition.
- case 'T':
- {
- ACE_SET_BITS (option_word_, NOTYPE);
- break;
- }
- // Print out the version and quit.
- case 'v':
- ACE_ERROR ((LM_ERROR,
- "%n: version %s\n%r\n",
- version_string,
- &Options::usage));
- ACE_OS::exit (0);
- /* NOTREACHED */
- break;
- // Exit with value of 0 (this is useful to check if gperf exists)
- case 'V':
- ACE_OS::exit (0);
- /* NOTREACHED */
- break;
- // Set the class name.
- case 'Z':
- {
- class_name_ = getopt.opt_arg ();
- break;
- }
- default:
- ACE_ERROR_RETURN ((LM_ERROR,
- "%r",
- &Options::usage),
- -1);
- }
-
- }
-
- if (argv[getopt.opt_ind ()] &&
- ACE_OS::freopen (argv[getopt.opt_ind ()],
- "r",
- stdin) == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Cannot open keyword file %p\n%r",
- argv[getopt.opt_ind ()],
- &Options::usage),
- -1);
- if (getopt.opt_ind () + 1 < argc)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Extra trailing arguments to %n.\n%r",
- usage),
- -1);
- return 0;
-}
-
-// True if option enable, else false.
-
-int
-Options::operator[] (Option_Type option)
-{
- return ACE_BIT_ENABLED (option_word_, option);
-}
-
-// Enables option OPT.
-
-void
-Options::operator = (enum Option_Type opt)
-{
- ACE_SET_BITS (option_word_, opt);
-}
-
-// Disables option OPT.
-
-bool
-Options::operator != (enum Option_Type opt)
-{
- // @@ Why is this inequality comparison operator clearing bits?
- ACE_CLR_BITS (option_word_, opt);
-
- return true;
-}
-
-// Initializes the key Iterator.
-
-void
-Options::reset (void)
-{
- key_pos_ = 0;
-}
-
-// Returns current key_position and advanced index.
-
-int
-Options::get (void)
-{
- return key_positions_[key_pos_++];
-}
-
-// Sets the size of the table size.
-
-void
-Options::asso_max (int r)
-{
- size_ = r;
-}
-
-// Returns the size of the table size.
-
-int
-Options::asso_max (void)
-{
- return size_;
-}
-
-// Returns total distinct key positions.
-
-u_int
-Options::max_keysig_size (void)
-{
- return total_keysig_size_;
-}
-
-// Sets total distinct key positions.
-
-void
-Options::keysig_size (u_int a_size)
-{
- total_keysig_size_ = a_size;
-}
-
-// Returns the jump value.
-
-int
-Options::jump (void)
-{
- return jump_;
-}
-
-// Returns the generated function name.
-
-const char *
-Options::function_name (void)
-{
- return function_name_;
-}
-
-// Returns the fill default
-
-const char *
-Options::fill_default (void)
-{
- return fill_default_;
-}
-
-// Returns the keyword key name.
-
-const char *
-Options::key_name (void)
-{
- return key_name_;
-}
-
-// Returns the hash function name.
-
-const char *
-Options::hash_name (void)
-{
- return hash_name_;
-}
-
-// Returns the generated class name.
-
-const char *
-Options::class_name (void)
-{
- return class_name_;
-}
-
-// Returns the initial associated character value.
-
-int
-Options::initial_value (void)
-{
- return initial_asso_value_;
-}
-
-// Returns the iterations value.
-
-int
-Options::iterations (void)
-{
- return iterations_;
-}
-
-// Returns the string used to delimit keywords from other attributes.
-
-const char *
-Options::delimiter (void)
-{
- return delimiters_;
-}
-
-// Gets the total number of switch statements to generate.
-
-int
-Options::total_switches (void)
-{
- return total_switches_;
-}
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Options.h b/ACE/apps/gperf/src/Options.h
deleted file mode 100644
index c53ba235a2d..00000000000
--- a/ACE/apps/gperf/src/Options.h
+++ /dev/null
@@ -1,190 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef OPTIONS_H
-#define OPTIONS_H
-
-#include "ace/Log_Msg.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#if defined (ACE_HAS_GPERF)
-
-// Enumerate the potential debugging Options.
-
-enum Option_Type
-{
- DEBUGGING = 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.
- INLINE = 020, // Generate code for inline functions.
- 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.
- CONSTANT = 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.
- MUTE = 0100000000, // Dont print the warnings.
- SKIPCLASS = 0200000000, // Skip the class definition part in the output while in C++ mode.
- SKIPSTRINGH = 0400000000, // Skip including the header file ace/OS_NS_string.h.
- BINARYSEARCH = 01000000000, // Generates Binary Search code.
- LINEARSEARCH = 02000000000 // Generates Linear Search 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... ;-(
-
-// PharLap ETS defines EOS as well... so if building for ETS, clear out
-// their EOS.
-#if defined (ACE_HAS_PHARLAP) && defined (EOS)
-# undef EOS
-#endif /* ACE_HAS_PHARLAP && EOS */
-
-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.
-};
-
-// @@ 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);
- int operator[] (Option_Type option);
- int parse_args (int argc, char *argv[]);
- void operator= (enum Option_Type);
- bool operator!= (enum Option_Type);
- static void print_options (void);
- static void asso_max (int r);
- static int asso_max (void);
- static void reset (void);
- static int get (void);
- static int iterations (void);
- static u_int max_keysig_size (void);
- static void keysig_size (u_int);
- static int jump (void);
- static int initial_value (void);
- static int total_switches (void);
- static const char *function_name (void);
- static const char *fill_default (void);
- static const char *key_name (void);
- static const char *class_name (void);
- static const char *hash_name (void);
- static const char *delimiter (void);
-
-private:
- static int option_word_;
- // Holds the user-specified Options.
-
- static int total_switches_;
- // Number of switch statements to generate.
-
- static u_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 iterations_;
- // Amount to iterate when a collision occurs.
-
- static int argc_;
- // Records count of command-line arguments.
-
- static char **argv_;
- // Stores a pointer to command-line vector.
-
- static const char *function_name_;
- // Names used for generated lookup function.
-
- static const char *fill_default_;
- // Expression used to assign default values in keyword table.
-
- 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.
-extern Options option;
-
-#endif /* ACE_HAS_GPERF */
-#endif /* OPTIONS_H */
diff --git a/ACE/apps/gperf/src/Vectors.cpp b/ACE/apps/gperf/src/Vectors.cpp
deleted file mode 100644
index 95706725549..00000000000
--- a/ACE/apps/gperf/src/Vectors.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "Vectors.h"
-
-ACE_RCSID(src, Vectors, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-// Counts occurrences of each key set character.
-int Vectors::occurrences[ACE_STANDARD_CHARACTER_SET_SIZE];
-
-// Value associated with each character.
-int Vectors::asso_values[ACE_STANDARD_CHARACTER_SET_SIZE];
-
-#endif /* ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/Vectors.h b/ACE/apps/gperf/src/Vectors.h
deleted file mode 100644
index 6555c3f50b7..00000000000
--- a/ACE/apps/gperf/src/Vectors.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef VECTORS_H
-#define VECTORS_H
-
-#include "ace/config-all.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#if defined (ACE_HAS_GPERF)
-
-// Do not change these values wantonly since GPERF depends on them..
-#define ACE_ASCII_SIZE 128
-#define ACE_EBCDIC_SIZE 256
-
-#if 'a' < 'A'
-#define ACE_HAS_EBCDIC
-#define ACE_STANDARD_CHARACTER_SET_SIZE 256
-#else
-#define ACE_HAS_ASCII
-#define ACE_STANDARD_CHARACTER_SET_SIZE 128
-#endif /* 'a' < 'A' */
-
-class Vectors
-{
- // = TITLE
- // Static class data members that are shared between several
- // classes via inheritance.
-public:
- static int occurrences[ACE_STANDARD_CHARACTER_SET_SIZE];
- // Counts occurrences of each key set character.
-
- static int asso_values[ACE_STANDARD_CHARACTER_SET_SIZE];
- // Value associated with each character.
-};
-
-#endif /* ACE_HAS_GPERF */
-#endif /* VECTORS_H */
diff --git a/ACE/apps/gperf/src/Version.cpp b/ACE/apps/gperf/src/Version.cpp
deleted file mode 100644
index d2967050e43..00000000000
--- a/ACE/apps/gperf/src/Version.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Current program version number.
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include "ace/ACE.h"
-
-ACE_RCSID(src, Version, "$Id$")
-
-const char *version_string = "2.8 (ACE version)";
diff --git a/ACE/apps/gperf/src/gperf.cpp b/ACE/apps/gperf/src/gperf.cpp
deleted file mode 100644
index c6a838e2874..00000000000
--- a/ACE/apps/gperf/src/gperf.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-// -*- C++ -*-
-
-// $Id$
-
-// Driver program for the gperf hash function generator.
-
-// Copyright (C) 1989 Free Software Foundation, Inc.
-// written by Douglas C. Schmidt (schmidt@cs.wustl.edu)
-
-// This file is part of GNU GPERF.
-
-// This program 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 2
-// of the License, or (at your option) any later version.
-
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-// Simple driver program for the gperf hash function generator. All
-// the hard work is done in class Gen_Perf and its class methods.
-
-#include "Gen_Perf.h"
-
-ACE_RCSID(src, gperf, "$Id$")
-
-#if defined (ACE_HAS_GPERF)
-
-#include "Options.h"
-#include "ace/OS_NS_time.h"
-#include "ace/OS_NS_stdio.h"
-#include "ace/OS_main.h"
-
-int
-ACE_TMAIN (int argc, ACE_TCHAR *argv[])
-{
- struct tm *tm;
- time_t clock;
-
- // Sets the Options.
- if (option.parse_args (argc, argv) == -1)
- return 1;
-
- ACE_OS::time (&clock);
- tm = ACE_OS::localtime (&clock);
-
- if (option[DEBUGGING])
- ACE_OS::printf ("/* starting time is %d:%02d:%02d */\n",
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
-
- // Initializes the key word list.
- Gen_Perf gperf;
-
- // Generates and prints the gperf hash table. Don't use exit here,
- // it skips the destructors.
- int status = gperf.run ();
-
- ACE_OS::time (&clock);
- tm = ACE_OS::localtime (&clock);
-
- if (option[DEBUGGING])
- ACE_OS::printf ("/* ending time is %d:%02d:%02d */\n",
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
- return status;
-}
-#else /* ! ACE_HAS_GPERF */
-int
-ACE_TMAIN (int argc, ACE_TCHAR *argv[])
-{
- ACE_UNUSED_ARG (argc);
- ACE_UNUSED_ARG (argv);
-
- ACE_ERROR_RETURN ((LM_ERROR,
- "gperf is not operational because "
- "ACE_HAS_GPERF was not enabled for the build\n"),
- 1);
-}
-#endif /* ! ACE_HAS_GPERF */
diff --git a/ACE/apps/gperf/src/gperf.mpc b/ACE/apps/gperf/src/gperf.mpc
deleted file mode 100644
index 81976d37aba..00000000000
--- a/ACE/apps/gperf/src/gperf.mpc
+++ /dev/null
@@ -1,20 +0,0 @@
-// -*- MPC -*-
-// $Id$
-
-project(gperf) : aceexe, install, crosscompile {
- install = $(ACE_ROOT)/bin
- avoids += uses_wchar
- exename = gperf
- Source_Files {
- gperf.cpp
- Options.cpp
- Iterator.cpp
- Gen_Perf.cpp
- Key_List.cpp
- List_Node.cpp
- Hash_Table.cpp
- Bool_Array.cpp
- Vectors.cpp
- Version.cpp
- }
-}