mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-03 05:29:22 +00:00
Improve option --pic. New options --string-pool-name, --null-strings.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* Handles parsing the Options provided to the user.
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-1998, 2000, 2002-2003 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 string pool. */
|
||||
static const char *const DEFAULT_STRINGPOOL_NAME = "stringpool";
|
||||
|
||||
/* Default delimiters that separate keywords from their attributes. */
|
||||
static const char *const DEFAULT_DELIMITERS = ",";
|
||||
|
||||
@@ -165,6 +168,13 @@ Options::long_usage (FILE * stream)
|
||||
" -P, --pic Optimize the generated table for inclusion in shared\n"
|
||||
" libraries. This reduces the startup time of programs\n"
|
||||
" using a shared library containing the generated code.\n");
|
||||
fprintf (stream,
|
||||
" -Q, --string-pool-name=NAME\n"
|
||||
" Specify name of string pool generated by option --pic.\n"
|
||||
" Default name is 'stringpool'.\n");
|
||||
fprintf (stream,
|
||||
" --null-strings Use NULL strings instead of empty strings for empty\n"
|
||||
" keyword table entries.\n");
|
||||
fprintf (stream,
|
||||
" -W, --word-array-name=NAME\n"
|
||||
" Specify name of word list array. Default name is\n"
|
||||
@@ -448,6 +458,7 @@ Options::Options ()
|
||||
_class_name (DEFAULT_CLASS_NAME),
|
||||
_hash_name (DEFAULT_HASH_NAME),
|
||||
_wordlist_name (DEFAULT_WORDLIST_NAME),
|
||||
_stringpool_name (DEFAULT_STRINGPOOL_NAME),
|
||||
_delimiters (DEFAULT_DELIMITERS),
|
||||
_key_positions ()
|
||||
{
|
||||
@@ -473,6 +484,7 @@ Options::~Options ()
|
||||
"\nENUM is........: %s"
|
||||
"\nINCLUDE is.....: %s"
|
||||
"\nGLOBAL is......: %s"
|
||||
"\nNULLSTRINGS is.: %s"
|
||||
"\nSHAREDLIB is...: %s"
|
||||
"\nSWITCH is......: %s"
|
||||
"\nNOTYPE is......: %s"
|
||||
@@ -483,6 +495,7 @@ Options::~Options ()
|
||||
"\nlookup function name = %s"
|
||||
"\nhash function name = %s"
|
||||
"\nword list name = %s"
|
||||
"\nstring pool name = %s"
|
||||
"\nslot name = %s"
|
||||
"\ninitializer suffix = %s"
|
||||
"\nasso_values iterations = %d"
|
||||
@@ -504,6 +517,7 @@ Options::~Options ()
|
||||
_option_word & ENUM ? "enabled" : "disabled",
|
||||
_option_word & INCLUDE ? "enabled" : "disabled",
|
||||
_option_word & GLOBAL ? "enabled" : "disabled",
|
||||
_option_word & NULLSTRINGS ? "enabled" : "disabled",
|
||||
_option_word & SHAREDLIB ? "enabled" : "disabled",
|
||||
_option_word & SWITCH ? "enabled" : "disabled",
|
||||
_option_word & NOTYPE ? "enabled" : "disabled",
|
||||
@@ -511,9 +525,10 @@ Options::~Options ()
|
||||
_option_word & NOLENGTH ? "enabled" : "disabled",
|
||||
_option_word & RANDOM ? "enabled" : "disabled",
|
||||
_option_word & DEBUG ? "enabled" : "disabled",
|
||||
_function_name, _hash_name, _wordlist_name, _slot_name,
|
||||
_initializer_suffix, _asso_iterations, _jump, _size_multiple,
|
||||
_initial_asso_value, _delimiters, _total_switches);
|
||||
_function_name, _hash_name, _wordlist_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
|
||||
@@ -610,6 +625,14 @@ Options::set_wordlist_name (const char *name)
|
||||
_wordlist_name = name;
|
||||
}
|
||||
|
||||
/* Sets the string pool name, if not already set. */
|
||||
void
|
||||
Options::set_stringpool_name (const char *name)
|
||||
{
|
||||
if (_stringpool_name == DEFAULT_STRINGPOOL_NAME)
|
||||
_stringpool_name = name;
|
||||
}
|
||||
|
||||
/* Sets the delimiters string, if not already set. */
|
||||
void
|
||||
Options::set_delimiters (const char *delimiters)
|
||||
@@ -656,6 +679,8 @@ static const struct option long_options[] =
|
||||
{ "occurrence-sort", no_argument, NULL, 'o' },
|
||||
{ "optimized-collision-resolution", no_argument, NULL, 'O' },
|
||||
{ "pic", no_argument, NULL, 'P' },
|
||||
{ "string-pool-name", required_argument, NULL, 'Q' },
|
||||
{ "null-strings", no_argument, NULL, CHAR_MAX + 3 },
|
||||
{ "random", no_argument, NULL, 'r' },
|
||||
{ "size-multiple", required_argument, NULL, 's' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
@@ -675,7 +700,7 @@ Options::parse_options (int argc, char *argv[])
|
||||
|
||||
while ((option_char =
|
||||
getopt_long (_argument_count, _argument_vector,
|
||||
"acCdDe:Ef:F:gGhH:i:Ij:k:K:lL:m:nN:oOpPrs:S:tTvW:Z:7",
|
||||
"acCdDe:Ef:F:gGhH:i:Ij:k:K:lL:m:nN:oOpPQ:rs:S:tTvW:Z:7",
|
||||
long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
@@ -872,6 +897,11 @@ Options::parse_options (int argc, char *argv[])
|
||||
_option_word |= SHAREDLIB;
|
||||
break;
|
||||
}
|
||||
case 'Q': /* Sets the name for the string pool. */
|
||||
{
|
||||
_stringpool_name = /*getopt*/optarg;
|
||||
break;
|
||||
}
|
||||
case 'r': /* Utilize randomness to initialize the associated values table. */
|
||||
{
|
||||
_option_word |= RANDOM;
|
||||
@@ -978,6 +1008,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
||||
_option_word |= UPPERLOWER;
|
||||
break;
|
||||
}
|
||||
case CHAR_MAX + 3: /* Use NULL instead of "". */
|
||||
{
|
||||
_option_word |= NULLSTRINGS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
short_usage (stderr);
|
||||
exit (1);
|
||||
|
||||
Reference in New Issue
Block a user