mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
Add option "-F", initializer suffix, to avoid warnings in gcc.
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -1,5 +1,21 @@
|
|||||||
2000-08-19 Bruno Haible <bruno@linuix.math.u-bordeaux.fr>
|
2000-08-19 Bruno Haible <bruno@linuix.math.u-bordeaux.fr>
|
||||||
|
|
||||||
|
Make the structure initializers customizable. Based on a patch by
|
||||||
|
Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
|
||||||
|
* src/options.h (Options::get_initializer_suffix,
|
||||||
|
Options::initializer_suffix): New declarations.
|
||||||
|
* src/options.icc (Options::get_initializer_suffix): New function.
|
||||||
|
* src/options.cc (DEFAULT_INITIALIZER_SUFFIX): New constant.
|
||||||
|
(Options::initializer_suffix): New variable.
|
||||||
|
(Options::long_usage): Document option "-F".
|
||||||
|
(Options constructor): Initialize initializer_suffix.
|
||||||
|
(Options destructor): Dump initializer_suffix.
|
||||||
|
(long_options): Add option "-F".
|
||||||
|
(Options::operator()): Accept option "-F". Sets initializer_suffix.
|
||||||
|
* src/key-list.cc (output_keyword_blank_entries): Output
|
||||||
|
initializer_suffix.
|
||||||
|
* doc/gperf.texi: Document option "-F".
|
||||||
|
|
||||||
* COPYING: Replace with GPL version 2 (with new FSF address and Y2K safe
|
* COPYING: Replace with GPL version 2 (with new FSF address and Y2K safe
|
||||||
year format).
|
year format).
|
||||||
|
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ the literal tab character.
|
|||||||
|
|
||||||
@item -t
|
@item -t
|
||||||
Allows you to include a @code{struct} type declaration for generated
|
Allows you to include a @code{struct} type declaration for generated
|
||||||
code. Any text before a pair of consecutive %% is consider part of the
|
code. Any text before a pair of consecutive %% is considered part of the
|
||||||
type declaration. Key words and additional fields may follow this, one
|
type declaration. Key words and additional fields may follow this, one
|
||||||
group of fields per line. A set of examples for generating perfect hash
|
group of fields per line. A set of examples for generating perfect hash
|
||||||
tables and functions for Ada, C, and G++, Pascal, and Modula 2 and 3
|
tables and functions for Ada, C, and G++, Pascal, and Modula 2 and 3
|
||||||
@@ -578,6 +578,13 @@ the keyword is @samp{name}. This option allows an arbitrary choice of
|
|||||||
identifier for this component, although it still must occur as the first
|
identifier for this component, although it still must occur as the first
|
||||||
field in your supplied @code{struct}.
|
field in your supplied @code{struct}.
|
||||||
|
|
||||||
|
@item -F @var{initializers}
|
||||||
|
This option is only useful when option @samp{-t} has been given.
|
||||||
|
It permits to specify initializers for the structure members following
|
||||||
|
@var{key name} in empty hash table entries. The list of initializers
|
||||||
|
should start with a comma. By default, the emitted code will
|
||||||
|
zero-initialize structure members following @var{key name}.
|
||||||
|
|
||||||
@item -H @var{hash function name}
|
@item -H @var{hash function name}
|
||||||
Allows you to specify the name for the generated hash function. Default
|
Allows you to specify the name for the generated hash function. Default
|
||||||
name is @samp{hash}. This option permits the use of two hash tables in the
|
name is @samp{hash}. This option permits the use of two hash tables in the
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Routines for building, ordering, and printing the keyword list.
|
/* Routines for building, ordering, and printing the keyword list.
|
||||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||||
|
|
||||||
This file is part of GNU GPERF.
|
This file is part of GNU GPERF.
|
||||||
@@ -1053,7 +1053,17 @@ output_keyword_entry (List_Node *temp, const char *indent)
|
|||||||
static void
|
static void
|
||||||
output_keyword_blank_entries (int count, const char *indent)
|
output_keyword_blank_entries (int count, const char *indent)
|
||||||
{
|
{
|
||||||
const int columns = 9;
|
int columns;
|
||||||
|
if (option[TYPE])
|
||||||
|
{
|
||||||
|
columns = 58 / (6 + strlen (option.get_initializer_suffix()));
|
||||||
|
if (columns == 0)
|
||||||
|
columns = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
columns = 9;
|
||||||
|
}
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@@ -1069,7 +1079,7 @@ output_keyword_blank_entries (int count, const char *indent)
|
|||||||
printf (", ");
|
printf (", ");
|
||||||
}
|
}
|
||||||
if (option[TYPE])
|
if (option[TYPE])
|
||||||
printf ("{\"\"}");
|
printf ("{\"\"%s}", option.get_initializer_suffix());
|
||||||
else
|
else
|
||||||
printf ("\"\"");
|
printf ("\"\"");
|
||||||
column++;
|
column++;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Handles parsing the Options provided to the user.
|
/* Handles parsing the Options provided to the user.
|
||||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||||
|
|
||||||
This file is part of GNU GPERF.
|
This file is part of GNU GPERF.
|
||||||
@@ -43,6 +43,9 @@ static const char *const DEFAULT_NAME = "in_word_set";
|
|||||||
/* Default name for the key component. */
|
/* Default name for the key component. */
|
||||||
static const char *const DEFAULT_KEY = "name";
|
static const char *const DEFAULT_KEY = "name";
|
||||||
|
|
||||||
|
/* Default struct initializer suffix. */
|
||||||
|
static const char *const DEFAULT_INITIALIZER_SUFFIX = "";
|
||||||
|
|
||||||
/* Default name for the generated class. */
|
/* Default name for the generated class. */
|
||||||
static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
|
static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
|
||||||
|
|
||||||
@@ -67,6 +70,7 @@ int Options::iterations;
|
|||||||
char **Options::argument_vector;
|
char **Options::argument_vector;
|
||||||
const char *Options::function_name;
|
const char *Options::function_name;
|
||||||
const char *Options::key_name;
|
const char *Options::key_name;
|
||||||
|
const char *Options::initializer_suffix;
|
||||||
const char *Options::class_name;
|
const char *Options::class_name;
|
||||||
const char *Options::hash_name;
|
const char *Options::hash_name;
|
||||||
const char *Options::wordlist_name;
|
const char *Options::wordlist_name;
|
||||||
@@ -116,6 +120,9 @@ Options::long_usage (FILE * strm)
|
|||||||
"Details in the output code:\n"
|
"Details in the output code:\n"
|
||||||
" -K, --slot-name=NAME Select name of the keyword component in the keyword\n"
|
" -K, --slot-name=NAME Select name of the keyword component in the keyword\n"
|
||||||
" structure.\n"
|
" structure.\n"
|
||||||
|
" -F, --initializer-suffix=INITIALIZERS\n"
|
||||||
|
" Initializers for additional components in the keyword\n"
|
||||||
|
" structure.\n"
|
||||||
" -H, --hash-fn-name=NAME\n"
|
" -H, --hash-fn-name=NAME\n"
|
||||||
" Specify name of generated hash function. Default is\n"
|
" Specify name of generated hash function. Default is\n"
|
||||||
" `hash'.\n"
|
" `hash'.\n"
|
||||||
@@ -266,6 +273,7 @@ Options::Options (void)
|
|||||||
option_word = DEFAULTCHARS | C;
|
option_word = DEFAULTCHARS | C;
|
||||||
function_name = DEFAULT_NAME;
|
function_name = DEFAULT_NAME;
|
||||||
key_name = DEFAULT_KEY;
|
key_name = DEFAULT_KEY;
|
||||||
|
initializer_suffix = DEFAULT_INITIALIZER_SUFFIX;
|
||||||
hash_name = DEFAULT_HASH_NAME;
|
hash_name = DEFAULT_HASH_NAME;
|
||||||
wordlist_name = DEFAULT_WORDLIST_NAME;
|
wordlist_name = DEFAULT_WORDLIST_NAME;
|
||||||
class_name = DEFAULT_CLASS_NAME;
|
class_name = DEFAULT_CLASS_NAME;
|
||||||
@@ -309,6 +317,7 @@ Options::~Options (void)
|
|||||||
"\nhash function name = %s"
|
"\nhash function name = %s"
|
||||||
"\nword list name = %s"
|
"\nword list name = %s"
|
||||||
"\nkey name = %s"
|
"\nkey name = %s"
|
||||||
|
"\ninitializer suffix = %s"
|
||||||
"\njump value = %d"
|
"\njump value = %d"
|
||||||
"\nmax associated value = %d"
|
"\nmax associated value = %d"
|
||||||
"\ninitial associated value = %d"
|
"\ninitial associated value = %d"
|
||||||
@@ -337,7 +346,8 @@ Options::~Options (void)
|
|||||||
option_word & SEVENBIT ? "enabled" : "disabled",
|
option_word & SEVENBIT ? "enabled" : "disabled",
|
||||||
iterations,
|
iterations,
|
||||||
function_name, hash_name, wordlist_name, key_name,
|
function_name, hash_name, wordlist_name, key_name,
|
||||||
jump, size - 1, initial_asso_value, delimiters, total_switches);
|
initializer_suffix, jump, size - 1, initial_asso_value,
|
||||||
|
delimiters, total_switches);
|
||||||
if (option_word & ALLCHARS)
|
if (option_word & ALLCHARS)
|
||||||
fprintf (stderr, "all characters are used in the hash function\n");
|
fprintf (stderr, "all characters are used in the hash function\n");
|
||||||
|
|
||||||
@@ -363,6 +373,7 @@ static const struct option long_options[] =
|
|||||||
{ "struct-type", no_argument, 0, 't' },
|
{ "struct-type", no_argument, 0, 't' },
|
||||||
{ "language", required_argument, 0, 'L' },
|
{ "language", required_argument, 0, 'L' },
|
||||||
{ "slot-name", required_argument, 0, 'K' },
|
{ "slot-name", required_argument, 0, 'K' },
|
||||||
|
{ "initializer-suffix", required_argument, 0, 'F' },
|
||||||
{ "hash-fn-name", required_argument, 0, 'H' },
|
{ "hash-fn-name", required_argument, 0, 'H' },
|
||||||
{ "lookup-fn-name", required_argument, 0, 'N' },
|
{ "lookup-fn-name", required_argument, 0, 'N' },
|
||||||
{ "class-name", required_argument, 0, 'Z' },
|
{ "class-name", required_argument, 0, 'Z' },
|
||||||
@@ -403,7 +414,7 @@ Options::operator() (int argc, char *argv[])
|
|||||||
|
|
||||||
while ((option_char =
|
while ((option_char =
|
||||||
getopt_long (argument_count, argument_vector,
|
getopt_long (argument_count, argument_vector,
|
||||||
"adcCDe:Ef:gGhH:i:Ij:k:K:lL:nN:oprs:S:tTvW:Z:7",
|
"adcCDe:Ef:F:gGhH:i:Ij:k:K:lL:nN:oprs:S:tTvW:Z:7",
|
||||||
long_options, (int *)0))
|
long_options, (int *)0))
|
||||||
!= -1)
|
!= -1)
|
||||||
{
|
{
|
||||||
@@ -453,11 +464,16 @@ Options::operator() (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'F':
|
||||||
|
{
|
||||||
|
initializer_suffix = /*getopt*/optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'g': /* Use the ``inline'' keyword for generated sub-routines, ifdef __GNUC__. */
|
case 'g': /* Use the ``inline'' keyword for generated sub-routines, ifdef __GNUC__. */
|
||||||
break; /* This is now the default. */
|
break; /* This is now the default. */
|
||||||
case 'G': /* Make the keyword table a global variable. */
|
case 'G': /* Make the keyword table a global variable. */
|
||||||
{
|
{
|
||||||
option_word |= GLOBAL;
|
option_word |= GLOBAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'h': /* Displays a list of helpful Options to the user. */
|
case 'h': /* Displays a list of helpful Options to the user. */
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* Handles parsing the Options provided to the user.
|
/* Handles parsing the Options provided to the user.
|
||||||
|
|
||||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||||
|
|
||||||
This file is part of GNU GPERF.
|
This file is part of GNU GPERF.
|
||||||
@@ -98,6 +98,7 @@ public:
|
|||||||
static int get_total_switches (void);
|
static int get_total_switches (void);
|
||||||
static const char *get_function_name (void);
|
static const char *get_function_name (void);
|
||||||
static const char *get_key_name (void);
|
static const char *get_key_name (void);
|
||||||
|
static const char *get_initializer_suffix (void);
|
||||||
static const char *get_class_name (void);
|
static const char *get_class_name (void);
|
||||||
static const char *get_hash_name (void);
|
static const char *get_hash_name (void);
|
||||||
static const char *get_wordlist_name (void);
|
static const char *get_wordlist_name (void);
|
||||||
@@ -116,6 +117,7 @@ private:
|
|||||||
static char **argument_vector; /* Stores a pointer to command-line vector. */
|
static char **argument_vector; /* Stores a pointer to command-line vector. */
|
||||||
static const char *function_name; /* Names used for generated lookup function. */
|
static const char *function_name; /* Names used for generated lookup function. */
|
||||||
static const char *key_name; /* Name used for keyword key. */
|
static const char *key_name; /* Name used for keyword key. */
|
||||||
|
static const char *initializer_suffix; /* Suffix for empty struct initializers. */
|
||||||
static const char *class_name; /* Name used for generated C++ class. */
|
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 *hash_name; /* Name used for generated hash function. */
|
||||||
static const char *wordlist_name; /* Name used for hash table array. */
|
static const char *wordlist_name; /* Name used for hash table array. */
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Inline Functions for options.{h,cc}.
|
/* Inline Functions for options.{h,cc}.
|
||||||
|
|
||||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||||
|
|
||||||
This file is part of GNU GPERF.
|
This file is part of GNU GPERF.
|
||||||
@@ -118,6 +118,14 @@ Options::get_key_name (void)
|
|||||||
return key_name;
|
return key_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns the struct initializer suffix. */
|
||||||
|
INLINE const char *
|
||||||
|
Options::get_initializer_suffix (void)
|
||||||
|
{
|
||||||
|
T (Trace t ("Options::get_initializer_suffix");)
|
||||||
|
return initializer_suffix;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the hash function name. */
|
/* Returns the hash function name. */
|
||||||
INLINE const char *
|
INLINE const char *
|
||||||
Options::get_hash_name (void)
|
Options::get_hash_name (void)
|
||||||
|
|||||||
Reference in New Issue
Block a user