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:
21
ChangeLog
21
ChangeLog
@@ -1,3 +1,24 @@
|
|||||||
|
2004-08-21 Bruce Lilly <blilly@erols.com>
|
||||||
|
|
||||||
|
* src/input.cc (Input::read_input): Accept length-table-name
|
||||||
|
declaration.
|
||||||
|
* src/options.h (Options::get_lengthtable_name,
|
||||||
|
Options::set_lengthtable_name): New declarations.
|
||||||
|
(Options): Add field _lengthtable_name.
|
||||||
|
* src/options.icc (Options::get_lengthtable_name): New inline method.
|
||||||
|
* src/options.cc (DEFAULT_LENGTHTABLE_NAME): New constant.
|
||||||
|
(Options::long_usage): Document --length-table-name option.
|
||||||
|
(Options::Options): Initialize _lengthtable_name field.
|
||||||
|
(Options::~Options): Update.
|
||||||
|
(Options::set_lengthtable_name): New method.
|
||||||
|
(long_options): Add option --length-table-name.
|
||||||
|
(Options::parse_options): Implement --length-table-name option.
|
||||||
|
* src/output.cc (Output::output_keylength_table, output_switch_case,
|
||||||
|
Output::output_lookup_function_body): Use option.get_lengthtable_name.
|
||||||
|
* doc/gperf.texi (Gperf Declarations): Document %define
|
||||||
|
length-table-name.
|
||||||
|
(Output Details): Document --length-table-name option.
|
||||||
|
|
||||||
2003-06-12 Bruno Haible <bruno@clisp.org>
|
2003-06-12 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
* gperf-3.0.1 released.
|
* gperf-3.0.1 released.
|
||||||
|
|||||||
5
NEWS
5
NEWS
@@ -1,3 +1,8 @@
|
|||||||
|
New in 3.1:
|
||||||
|
|
||||||
|
* Added option --length-table-name.
|
||||||
|
* Added declaration %define length-table-name.
|
||||||
|
|
||||||
New in 3.0.1:
|
New in 3.0.1:
|
||||||
|
|
||||||
* Bug fix.
|
* Bug fix.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
@c some day we should @include version.texi instead of defining
|
@c some day we should @include version.texi instead of defining
|
||||||
@c these values at hand.
|
@c these values at hand.
|
||||||
@set UPDATED 12 June 2003
|
@set UPDATED 22 August 2004
|
||||||
@set EDITION 3.0.1
|
@set EDITION 3.0.1
|
||||||
@set VERSION 3.0.1
|
@set VERSION 3.0.1
|
||||||
@c ---------------------
|
@c ---------------------
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
This file documents the features of the GNU Perfect Hash Function
|
This file documents the features of the GNU Perfect Hash Function
|
||||||
Generator @value{VERSION}.
|
Generator @value{VERSION}.
|
||||||
|
|
||||||
Copyright @copyright{} 1989-2003 Free Software Foundation, Inc.
|
Copyright @copyright{} 1989-2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Permission is granted to make and distribute verbatim copies of this
|
Permission is granted to make and distribute verbatim copies of this
|
||||||
manual provided the copyright notice and this permission notice are
|
manual provided the copyright notice and this permission notice are
|
||||||
@@ -66,7 +66,7 @@ Software Foundation instead of in the original English.
|
|||||||
|
|
||||||
@page
|
@page
|
||||||
@vskip 0pt plus 1filll
|
@vskip 0pt plus 1filll
|
||||||
Copyright @copyright{} 1989-2003 Free Software Foundation, Inc.
|
Copyright @copyright{} 1989-2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
|
||||||
Permission is granted to make and distribute verbatim copies of
|
Permission is granted to make and distribute verbatim copies of
|
||||||
@@ -605,6 +605,13 @@ hash table. Default name is @samp{wordlist}. This option permits the
|
|||||||
use of two hash tables in the same file, even when the option @samp{-G}
|
use of two hash tables in the same file, even when the option @samp{-G}
|
||||||
(or, equivalently, the @samp{%global-table} declaration) is given.
|
(or, equivalently, the @samp{%global-table} declaration) is given.
|
||||||
|
|
||||||
|
@item %define length-table-name @var{name}
|
||||||
|
@cindex @samp{%define length-table-name}
|
||||||
|
Allows you to specify the name for the generated array containing the
|
||||||
|
length table. Default name is @samp{lengthtable}. This option permits the
|
||||||
|
use of two length tables in the same file, even when the option @samp{-G}
|
||||||
|
(or, equivalently, the @samp{%global-table} declaration) is given.
|
||||||
|
|
||||||
@item %switch=@var{count}
|
@item %switch=@var{count}
|
||||||
@cindex @samp{%switch}
|
@cindex @samp{%switch}
|
||||||
Causes the generated C code to use a @code{switch} statement scheme,
|
Causes the generated C code to use a @code{switch} statement scheme,
|
||||||
@@ -1082,6 +1089,13 @@ hash table. Default name is @samp{wordlist}. This option permits the
|
|||||||
use of two hash tables in the same file, even when the option @samp{-G}
|
use of two hash tables in the same file, even when the option @samp{-G}
|
||||||
(or, equivalently, the @samp{%global-table} declaration) is given.
|
(or, equivalently, the @samp{%global-table} declaration) is given.
|
||||||
|
|
||||||
|
@itemx --length-table-name=@var{length-table-array-name}
|
||||||
|
@cindex Array name
|
||||||
|
Allows you to specify the name for the generated array containing the
|
||||||
|
length table. Default name is @samp{lengthtable}. This option permits the
|
||||||
|
use of two length tables in the same file, even when the option @samp{-G}
|
||||||
|
(or, equivalently, the @samp{%global-table} declaration) is given.
|
||||||
|
|
||||||
@item -S @var{total-switch-statements}
|
@item -S @var{total-switch-statements}
|
||||||
@itemx --switch=@var{total-switch-statements}
|
@itemx --switch=@var{total-switch-statements}
|
||||||
@cindex @code{switch}
|
@cindex @code{switch}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Input routines.
|
/* Input routines.
|
||||||
Copyright (C) 1989-1998, 2002-2003 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2002-2004 Free Software Foundation, Inc.
|
||||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||||
and Bruno Haible <bruno@clisp.org>.
|
and Bruno Haible <bruno@clisp.org>.
|
||||||
|
|
||||||
@@ -552,6 +552,11 @@ Input::read_input ()
|
|||||||
option.set_wordlist_name (arg);
|
option.set_wordlist_name (arg);
|
||||||
else
|
else
|
||||||
|
|
||||||
|
if (is_define_declaration (line, line_end, lineno,
|
||||||
|
"length-table-name", &arg))
|
||||||
|
option.set_lengthtable_name (arg);
|
||||||
|
else
|
||||||
|
|
||||||
if (is_declaration_with_arg (line, line_end, lineno,
|
if (is_declaration_with_arg (line, line_end, lineno,
|
||||||
"switch", &arg))
|
"switch", &arg))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Handles parsing the Options provided to the user.
|
/* 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>
|
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||||
and Bruno Haible <bruno@clisp.org>.
|
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. */
|
/* Default name for generated hash table array. */
|
||||||
static const char *const DEFAULT_WORDLIST_NAME = "wordlist";
|
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. */
|
/* Default name for string pool. */
|
||||||
static const char *const DEFAULT_STRINGPOOL_NAME = "stringpool";
|
static const char *const DEFAULT_STRINGPOOL_NAME = "stringpool";
|
||||||
|
|
||||||
@@ -179,6 +182,10 @@ Options::long_usage (FILE * stream)
|
|||||||
" -W, --word-array-name=NAME\n"
|
" -W, --word-array-name=NAME\n"
|
||||||
" Specify name of word list array. Default name is\n"
|
" Specify name of word list array. Default name is\n"
|
||||||
" 'wordlist'.\n");
|
" 'wordlist'.\n");
|
||||||
|
fprintf (stream,
|
||||||
|
" --length-table-name=NAME\n"
|
||||||
|
" Specify name of length table array. Default name is\n"
|
||||||
|
" 'lengthtable'.\n");
|
||||||
fprintf (stream,
|
fprintf (stream,
|
||||||
" -S, --switch=COUNT Causes the generated C code to use a switch\n"
|
" -S, --switch=COUNT Causes the generated C code to use a switch\n"
|
||||||
" statement scheme, rather than an array lookup table.\n"
|
" statement scheme, rather than an array lookup table.\n"
|
||||||
@@ -458,6 +465,7 @@ Options::Options ()
|
|||||||
_class_name (DEFAULT_CLASS_NAME),
|
_class_name (DEFAULT_CLASS_NAME),
|
||||||
_hash_name (DEFAULT_HASH_NAME),
|
_hash_name (DEFAULT_HASH_NAME),
|
||||||
_wordlist_name (DEFAULT_WORDLIST_NAME),
|
_wordlist_name (DEFAULT_WORDLIST_NAME),
|
||||||
|
_lengthtable_name (DEFAULT_LENGTHTABLE_NAME),
|
||||||
_stringpool_name (DEFAULT_STRINGPOOL_NAME),
|
_stringpool_name (DEFAULT_STRINGPOOL_NAME),
|
||||||
_delimiters (DEFAULT_DELIMITERS),
|
_delimiters (DEFAULT_DELIMITERS),
|
||||||
_key_positions ()
|
_key_positions ()
|
||||||
@@ -495,6 +503,7 @@ Options::~Options ()
|
|||||||
"\nlookup function name = %s"
|
"\nlookup function name = %s"
|
||||||
"\nhash function name = %s"
|
"\nhash function name = %s"
|
||||||
"\nword list name = %s"
|
"\nword list name = %s"
|
||||||
|
"\nlength table name = %s"
|
||||||
"\nstring pool name = %s"
|
"\nstring pool name = %s"
|
||||||
"\nslot name = %s"
|
"\nslot name = %s"
|
||||||
"\ninitializer suffix = %s"
|
"\ninitializer suffix = %s"
|
||||||
@@ -525,10 +534,10 @@ Options::~Options ()
|
|||||||
_option_word & NOLENGTH ? "enabled" : "disabled",
|
_option_word & NOLENGTH ? "enabled" : "disabled",
|
||||||
_option_word & RANDOM ? "enabled" : "disabled",
|
_option_word & RANDOM ? "enabled" : "disabled",
|
||||||
_option_word & DEBUG ? "enabled" : "disabled",
|
_option_word & DEBUG ? "enabled" : "disabled",
|
||||||
_function_name, _hash_name, _wordlist_name, _stringpool_name,
|
_function_name, _hash_name, _wordlist_name, _lengthtable_name,
|
||||||
_slot_name, _initializer_suffix, _asso_iterations, _jump,
|
_stringpool_name, _slot_name, _initializer_suffix,
|
||||||
_size_multiple, _initial_asso_value, _delimiters,
|
_asso_iterations, _jump, _size_multiple, _initial_asso_value,
|
||||||
_total_switches);
|
_delimiters, _total_switches);
|
||||||
if (_key_positions.is_useall())
|
if (_key_positions.is_useall())
|
||||||
fprintf (stderr, "all characters are used in the hash function\n");
|
fprintf (stderr, "all characters are used in the hash function\n");
|
||||||
else
|
else
|
||||||
@@ -633,6 +642,14 @@ Options::set_wordlist_name (const char *name)
|
|||||||
_wordlist_name = 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. */
|
/* Sets the string pool name, if not already set. */
|
||||||
void
|
void
|
||||||
Options::set_stringpool_name (const char *name)
|
Options::set_stringpool_name (const char *name)
|
||||||
@@ -673,6 +690,7 @@ static const struct option long_options[] =
|
|||||||
{ "includes", no_argument, NULL, 'I' },
|
{ "includes", no_argument, NULL, 'I' },
|
||||||
{ "global-table", no_argument, NULL, 'G' },
|
{ "global-table", no_argument, NULL, 'G' },
|
||||||
{ "word-array-name", required_argument, NULL, 'W' },
|
{ "word-array-name", required_argument, NULL, 'W' },
|
||||||
|
{ "length-table-name", required_argument, NULL, CHAR_MAX + 4 },
|
||||||
{ "switch", required_argument, NULL, 'S' },
|
{ "switch", required_argument, NULL, 'S' },
|
||||||
{ "omit-struct-type", no_argument, NULL, 'T' },
|
{ "omit-struct-type", no_argument, NULL, 'T' },
|
||||||
{ "key-positions", required_argument, NULL, 'k' },
|
{ "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;
|
_option_word |= NULLSTRINGS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CHAR_MAX + 4: /* Sets the name for the length table array. */
|
||||||
|
{
|
||||||
|
_lengthtable_name = /*getopt*/optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
short_usage (stderr);
|
short_usage (stderr);
|
||||||
exit (1);
|
exit (1);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* Handles parsing the Options provided to the user.
|
/* 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>
|
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||||
and Bruno Haible <bruno@clisp.org>.
|
and Bruno Haible <bruno@clisp.org>.
|
||||||
|
|
||||||
@@ -194,6 +194,11 @@ public:
|
|||||||
/* Sets the hash table array name, if not already set. */
|
/* Sets the hash table array name, if not already set. */
|
||||||
void set_wordlist_name (const char *name);
|
void set_wordlist_name (const char *name);
|
||||||
|
|
||||||
|
/* Returns the length table array name. */
|
||||||
|
const char * get_lengthtable_name () const;
|
||||||
|
/* Sets the length table array name, if not already set. */
|
||||||
|
void set_lengthtable_name (const char *name);
|
||||||
|
|
||||||
/* Returns the string pool name. */
|
/* Returns the string pool name. */
|
||||||
const char * get_stringpool_name () const;
|
const char * get_stringpool_name () const;
|
||||||
/* Sets the string pool name, if not already set. */
|
/* Sets the string pool name, if not already set. */
|
||||||
@@ -265,6 +270,9 @@ private:
|
|||||||
/* Name used for hash table array. */
|
/* Name used for hash table array. */
|
||||||
const char * _wordlist_name;
|
const char * _wordlist_name;
|
||||||
|
|
||||||
|
/* Name used for length table array. */
|
||||||
|
const char * _lengthtable_name;
|
||||||
|
|
||||||
/* Name used for the string pool. */
|
/* Name used for the string pool. */
|
||||||
const char * _stringpool_name;
|
const char * _stringpool_name;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Inline Functions for options.{h,cc}.
|
/* Inline Functions for options.{h,cc}.
|
||||||
|
|
||||||
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>
|
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||||
and Bruno Haible <bruno@clisp.org>.
|
and Bruno Haible <bruno@clisp.org>.
|
||||||
|
|
||||||
@@ -128,6 +128,13 @@ Options::get_wordlist_name () const
|
|||||||
return _wordlist_name;
|
return _wordlist_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns the length table array name. */
|
||||||
|
INLINE const char *
|
||||||
|
Options::get_lengthtable_name () const
|
||||||
|
{
|
||||||
|
return _lengthtable_name;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the string pool name. */
|
/* Returns the string pool name. */
|
||||||
INLINE const char *
|
INLINE const char *
|
||||||
Options::get_stringpool_name () const
|
Options::get_stringpool_name () const
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Output routines.
|
/* Output routines.
|
||||||
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>
|
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||||
and Bruno Haible <bruno@clisp.org>.
|
and Bruno Haible <bruno@clisp.org>.
|
||||||
|
|
||||||
@@ -916,9 +916,11 @@ Output::output_keylength_table () const
|
|||||||
const int columns = 14;
|
const int columns = 14;
|
||||||
const char * const indent = option[GLOBAL] ? "" : " ";
|
const char * const indent = option[GLOBAL] ? "" : " ";
|
||||||
|
|
||||||
printf ("%sstatic %s%s lengthtable[] =\n%s {",
|
printf ("%sstatic %s%s %s[] =\n"
|
||||||
|
"%s {",
|
||||||
indent, const_readonly_array,
|
indent, const_readonly_array,
|
||||||
smallest_integral_type (_max_key_len),
|
smallest_integral_type (_max_key_len),
|
||||||
|
option.get_lengthtable_name (),
|
||||||
indent);
|
indent);
|
||||||
|
|
||||||
/* Generate an array of lengths, similar to output_keyword_table. */
|
/* Generate an array of lengths, similar to output_keyword_table. */
|
||||||
@@ -1423,8 +1425,8 @@ output_switch_case (KeywordExt_List *list, int indent, int *jumps_away)
|
|||||||
if (option[DUP] && list->first()->_duplicate_link)
|
if (option[DUP] && list->first()->_duplicate_link)
|
||||||
{
|
{
|
||||||
if (option[LENTABLE])
|
if (option[LENTABLE])
|
||||||
printf ("%*slengthptr = &lengthtable[%d];\n",
|
printf ("%*slengthptr = &%s[%d];\n",
|
||||||
indent, "", list->first()->_final_index);
|
indent, "", option.get_lengthtable_name (), list->first()->_final_index);
|
||||||
printf ("%*swordptr = &%s[%d];\n",
|
printf ("%*swordptr = &%s[%d];\n",
|
||||||
indent, "", option.get_wordlist_name (), list->first()->_final_index);
|
indent, "", option.get_wordlist_name (), list->first()->_final_index);
|
||||||
|
|
||||||
@@ -1682,8 +1684,8 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
if (option[LENTABLE])
|
if (option[LENTABLE])
|
||||||
{
|
{
|
||||||
printf ("%*s {\n"
|
printf ("%*s {\n"
|
||||||
"%*s if (len == lengthtable[index])\n",
|
"%*s if (len == %s[index])\n",
|
||||||
indent, "", indent, "");
|
indent, "", indent, "", option.get_lengthtable_name ());
|
||||||
indent += 4;
|
indent += 4;
|
||||||
}
|
}
|
||||||
printf ("%*s {\n"
|
printf ("%*s {\n"
|
||||||
@@ -1721,8 +1723,9 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
"%*s register int offset = - 1 - TOTAL_KEYWORDS - index;\n",
|
"%*s register int offset = - 1 - TOTAL_KEYWORDS - index;\n",
|
||||||
indent, "", indent, "", indent, "");
|
indent, "", indent, "", indent, "");
|
||||||
if (option[LENTABLE])
|
if (option[LENTABLE])
|
||||||
printf ("%*s register %s%s *lengthptr = &lengthtable[TOTAL_KEYWORDS + lookup[offset]];\n",
|
printf ("%*s register %s%s *lengthptr = &%s[TOTAL_KEYWORDS + lookup[offset]];\n",
|
||||||
indent, "", const_always, smallest_integral_type (_max_key_len));
|
indent, "", const_always, smallest_integral_type (_max_key_len),
|
||||||
|
option.get_lengthtable_name ());
|
||||||
printf ("%*s register ",
|
printf ("%*s register ",
|
||||||
indent, "");
|
indent, "");
|
||||||
output_const_type (const_readonly_array, _wordlist_eltype);
|
output_const_type (const_readonly_array, _wordlist_eltype);
|
||||||
@@ -1781,8 +1784,8 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
int indent = 8;
|
int indent = 8;
|
||||||
if (option[LENTABLE])
|
if (option[LENTABLE])
|
||||||
{
|
{
|
||||||
printf ("%*sif (len == lengthtable[key])\n",
|
printf ("%*sif (len == %s[key])\n",
|
||||||
indent, "");
|
indent, "", option.get_lengthtable_name ());
|
||||||
indent += 2;
|
indent += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user