1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Add option "-F", initializer suffix, to avoid warnings in gcc.

This commit is contained in:
Bruno Haible
2000-08-19 08:47:58 +00:00
parent 018913610b
commit 891da43ca2
6 changed files with 69 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/* 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)
This file is part of GNU GPERF.
@@ -1053,7 +1053,17 @@ output_keyword_entry (List_Node *temp, const char *indent)
static void
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;
for (int i = 0; i < count; i++)
{
@@ -1069,7 +1079,7 @@ output_keyword_blank_entries (int count, const char *indent)
printf (", ");
}
if (option[TYPE])
printf ("{\"\"}");
printf ("{\"\"%s}", option.get_initializer_suffix());
else
printf ("\"\"");
column++;

View File

@@ -1,5 +1,5 @@
/* 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)
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. */
static const char *const DEFAULT_KEY = "name";
/* Default struct initializer suffix. */
static const char *const DEFAULT_INITIALIZER_SUFFIX = "";
/* Default name for the generated class. */
static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
@@ -67,6 +70,7 @@ int Options::iterations;
char **Options::argument_vector;
const char *Options::function_name;
const char *Options::key_name;
const char *Options::initializer_suffix;
const char *Options::class_name;
const char *Options::hash_name;
const char *Options::wordlist_name;
@@ -116,6 +120,9 @@ Options::long_usage (FILE * strm)
"Details in the output code:\n"
" -K, --slot-name=NAME Select name of the keyword component in the keyword\n"
" structure.\n"
" -F, --initializer-suffix=INITIALIZERS\n"
" Initializers for additional components in the keyword\n"
" structure.\n"
" -H, --hash-fn-name=NAME\n"
" Specify name of generated hash function. Default is\n"
" `hash'.\n"
@@ -266,6 +273,7 @@ Options::Options (void)
option_word = DEFAULTCHARS | C;
function_name = DEFAULT_NAME;
key_name = DEFAULT_KEY;
initializer_suffix = DEFAULT_INITIALIZER_SUFFIX;
hash_name = DEFAULT_HASH_NAME;
wordlist_name = DEFAULT_WORDLIST_NAME;
class_name = DEFAULT_CLASS_NAME;
@@ -309,6 +317,7 @@ Options::~Options (void)
"\nhash function name = %s"
"\nword list name = %s"
"\nkey name = %s"
"\ninitializer suffix = %s"
"\njump value = %d"
"\nmax associated value = %d"
"\ninitial associated value = %d"
@@ -337,7 +346,8 @@ Options::~Options (void)
option_word & SEVENBIT ? "enabled" : "disabled",
iterations,
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)
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' },
{ "language", required_argument, 0, 'L' },
{ "slot-name", required_argument, 0, 'K' },
{ "initializer-suffix", required_argument, 0, 'F' },
{ "hash-fn-name", required_argument, 0, 'H' },
{ "lookup-fn-name", required_argument, 0, 'N' },
{ "class-name", required_argument, 0, 'Z' },
@@ -403,7 +414,7 @@ Options::operator() (int argc, char *argv[])
while ((option_char =
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))
!= -1)
{
@@ -453,11 +464,16 @@ Options::operator() (int argc, char *argv[])
}
break;
}
case 'F':
{
initializer_suffix = /*getopt*/optarg;
break;
}
case 'g': /* Use the ``inline'' keyword for generated sub-routines, ifdef __GNUC__. */
break; /* This is now the default. */
case 'G': /* Make the keyword table a global variable. */
{
option_word |= GLOBAL;
option_word |= GLOBAL;
break;
}
case 'h': /* Displays a list of helpful Options to the user. */

View File

@@ -2,7 +2,7 @@
/* 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)
This file is part of GNU GPERF.
@@ -98,6 +98,7 @@ public:
static int get_total_switches (void);
static const char *get_function_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_hash_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 const char *function_name; /* Names used for generated lookup function. */
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 *hash_name; /* Name used for generated hash function. */
static const char *wordlist_name; /* Name used for hash table array. */

View File

@@ -1,6 +1,6 @@
/* 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)
This file is part of GNU GPERF.
@@ -118,6 +118,14 @@ Options::get_key_name (void)
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. */
INLINE const char *
Options::get_hash_name (void)