1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Add a length-table-name option and declaration.

This commit is contained in:
Bruno Haible
2004-08-22 15:52:15 +00:00
parent 6bbbca983f
commit e5f2f1dc44
8 changed files with 107 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
/* Handles parsing the Options provided to the user.
Copyright (C) 1989-1998, 2000, 2002-2003 Free Software Foundation, Inc.
Copyright (C) 1989-1998, 2000, 2002-2004 Free Software Foundation, Inc.
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
and Bruno Haible <bruno@clisp.org>.
@@ -58,6 +58,9 @@ static const char *const DEFAULT_HASH_NAME = "hash";
/* Default name for generated hash table array. */
static const char *const DEFAULT_WORDLIST_NAME = "wordlist";
/* Default name for generated length table array. */
static const char *const DEFAULT_LENGTHTABLE_NAME = "lengthtable";
/* Default name for string pool. */
static const char *const DEFAULT_STRINGPOOL_NAME = "stringpool";
@@ -179,6 +182,10 @@ Options::long_usage (FILE * stream)
" -W, --word-array-name=NAME\n"
" Specify name of word list array. Default name is\n"
" 'wordlist'.\n");
fprintf (stream,
" --length-table-name=NAME\n"
" Specify name of length table array. Default name is\n"
" 'lengthtable'.\n");
fprintf (stream,
" -S, --switch=COUNT Causes the generated C code to use a switch\n"
" statement scheme, rather than an array lookup table.\n"
@@ -458,6 +465,7 @@ Options::Options ()
_class_name (DEFAULT_CLASS_NAME),
_hash_name (DEFAULT_HASH_NAME),
_wordlist_name (DEFAULT_WORDLIST_NAME),
_lengthtable_name (DEFAULT_LENGTHTABLE_NAME),
_stringpool_name (DEFAULT_STRINGPOOL_NAME),
_delimiters (DEFAULT_DELIMITERS),
_key_positions ()
@@ -495,6 +503,7 @@ Options::~Options ()
"\nlookup function name = %s"
"\nhash function name = %s"
"\nword list name = %s"
"\nlength table name = %s"
"\nstring pool name = %s"
"\nslot name = %s"
"\ninitializer suffix = %s"
@@ -525,10 +534,10 @@ Options::~Options ()
_option_word & NOLENGTH ? "enabled" : "disabled",
_option_word & RANDOM ? "enabled" : "disabled",
_option_word & DEBUG ? "enabled" : "disabled",
_function_name, _hash_name, _wordlist_name, _stringpool_name,
_slot_name, _initializer_suffix, _asso_iterations, _jump,
_size_multiple, _initial_asso_value, _delimiters,
_total_switches);
_function_name, _hash_name, _wordlist_name, _lengthtable_name,
_stringpool_name, _slot_name, _initializer_suffix,
_asso_iterations, _jump, _size_multiple, _initial_asso_value,
_delimiters, _total_switches);
if (_key_positions.is_useall())
fprintf (stderr, "all characters are used in the hash function\n");
else
@@ -633,6 +642,14 @@ Options::set_wordlist_name (const char *name)
_wordlist_name = name;
}
/* Sets the length table array name, if not already set. */
void
Options::set_lengthtable_name (const char *name)
{
if (_lengthtable_name == DEFAULT_LENGTHTABLE_NAME)
_lengthtable_name = name;
}
/* Sets the string pool name, if not already set. */
void
Options::set_stringpool_name (const char *name)
@@ -673,6 +690,7 @@ static const struct option long_options[] =
{ "includes", no_argument, NULL, 'I' },
{ "global-table", no_argument, NULL, 'G' },
{ "word-array-name", required_argument, NULL, 'W' },
{ "length-table-name", required_argument, NULL, CHAR_MAX + 4 },
{ "switch", required_argument, NULL, 'S' },
{ "omit-struct-type", no_argument, NULL, 'T' },
{ "key-positions", required_argument, NULL, 'k' },
@@ -1021,6 +1039,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
_option_word |= NULLSTRINGS;
break;
}
case CHAR_MAX + 4: /* Sets the name for the length table array. */
{
_lengthtable_name = /*getopt*/optarg;
break;
}
default:
short_usage (stderr);
exit (1);