mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
Cleanup options.
Improve usage message. Improve output of options like --key-positions=1,2,$.
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
2002-12-10 Bruno Haible <bruno@clisp.org>
|
2002-12-10 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
* src/options.h: Reorder enum values.
|
||||||
|
(Options::short_usage, Options::long_usage): Make static.
|
||||||
|
* src/options.cc (Options::short_usage); No longer print a monster
|
||||||
|
usage line.
|
||||||
|
(Options::print_options): Improve output of options like
|
||||||
|
--key-positions=1,2,$.
|
||||||
|
(Options::~Options): Update.
|
||||||
|
|
||||||
* src/options.h (UPPERLOWER): New enum value.
|
* src/options.h (UPPERLOWER): New enum value.
|
||||||
* src/options.cc (Options::long_usage): Document option --ignore-case.
|
* src/options.cc (Options::long_usage): Document option --ignore-case.
|
||||||
(Options::~Options): Update.
|
(Options::~Options): Update.
|
||||||
|
|||||||
155
src/options.cc
155
src/options.cc
@@ -61,18 +61,17 @@ static const char *const DEFAULT_WORDLIST_NAME = "wordlist";
|
|||||||
/* Default delimiters that separate keywords from their attributes. */
|
/* Default delimiters that separate keywords from their attributes. */
|
||||||
static const char *const DEFAULT_DELIMITERS = ",";
|
static const char *const DEFAULT_DELIMITERS = ",";
|
||||||
|
|
||||||
/* Prints program usage to given stream. */
|
/* Prints program usage to given stream. */
|
||||||
|
|
||||||
void
|
void
|
||||||
Options::short_usage (FILE * stream) const
|
Options::short_usage (FILE * stream)
|
||||||
{
|
{
|
||||||
fprintf (stream, "Usage: %s [-cCdDef[num]F<initializers>GhH<hashname>i<init>Ij<jump>k<keys>K<keyname>lL<language>m<num>nN<function name>oPrs<size>S<switches>tTvW<wordlistname>Z<class name>7] [input-file]\n"
|
fprintf (stream,
|
||||||
"Try '%s --help' for more information.\n",
|
"Try '%s --help' for more information.\n", program_name);
|
||||||
program_name, program_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Options::long_usage (FILE * stream) const
|
Options::long_usage (FILE * stream)
|
||||||
{
|
{
|
||||||
fprintf (stream,
|
fprintf (stream,
|
||||||
"GNU 'gperf' generates perfect hash functions.\n");
|
"GNU 'gperf' generates perfect hash functions.\n");
|
||||||
@@ -254,11 +253,9 @@ Options::long_usage (FILE * stream) const
|
|||||||
void
|
void
|
||||||
Options::print_options () const
|
Options::print_options () const
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
printf ("/* Command-line: ");
|
printf ("/* Command-line: ");
|
||||||
|
|
||||||
for (i = 0; i < _argument_count; i++)
|
for (int i = 0; i < _argument_count; i++)
|
||||||
{
|
{
|
||||||
const char *arg = _argument_vector[i];
|
const char *arg = _argument_vector[i];
|
||||||
|
|
||||||
@@ -272,6 +269,20 @@ Options::print_options () const
|
|||||||
putchar (*arg);
|
putchar (*arg);
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
|
else if (*arg == '-')
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
putchar (*arg);
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
while (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z' || *arg == '-');
|
||||||
|
if (*arg == '=')
|
||||||
|
{
|
||||||
|
putchar (*arg);
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (strpbrk (arg, "\t\n !\"#$&'()*;<>?[\\]`{|}~") != NULL)
|
if (strpbrk (arg, "\t\n !\"#$&'()*;<>?[\\]`{|}~") != NULL)
|
||||||
{
|
{
|
||||||
@@ -419,7 +430,7 @@ PositionStringParser::nextPosition ()
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Sets the default Options. */
|
/* Sets the default Options. */
|
||||||
|
|
||||||
Options::Options ()
|
Options::Options ()
|
||||||
: _option_word (C),
|
: _option_word (C),
|
||||||
@@ -442,32 +453,33 @@ Options::Options ()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dumps option status when debug is set. */
|
/* Dumps option status when debugging is enabled. */
|
||||||
|
|
||||||
Options::~Options ()
|
Options::~Options ()
|
||||||
{
|
{
|
||||||
if (_option_word & DEBUG)
|
if (_option_word & DEBUG)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\ndumping Options:"
|
fprintf (stderr, "\ndumping Options:"
|
||||||
"\nDEBUG is.......: %s"
|
|
||||||
"\nTYPE is........: %s"
|
"\nTYPE is........: %s"
|
||||||
"\nRANDOM is......: %s"
|
"\nUPPERLOWER is..: %s"
|
||||||
"\nSWITCH is......: %s"
|
|
||||||
"\nNOLENGTH is....: %s"
|
|
||||||
"\nLENTABLE is....: %s"
|
|
||||||
"\nDUP is.........: %s"
|
|
||||||
"\nCOMP is........: %s"
|
|
||||||
"\nNOTYPE is......: %s"
|
|
||||||
"\nGLOBAL is......: %s"
|
|
||||||
"\nCONST is.......: %s"
|
|
||||||
"\nKRC is.........: %s"
|
"\nKRC is.........: %s"
|
||||||
"\nC is...........: %s"
|
"\nC is...........: %s"
|
||||||
"\nANSIC is.......: %s"
|
"\nANSIC is.......: %s"
|
||||||
"\nCPLUSPLUS is...: %s"
|
"\nCPLUSPLUS is...: %s"
|
||||||
|
"\nSEVENBIT is....: %s"
|
||||||
|
"\nLENTABLE is....: %s"
|
||||||
|
"\nCOMP is........: %s"
|
||||||
|
"\nCONST is.......: %s"
|
||||||
"\nENUM is........: %s"
|
"\nENUM is........: %s"
|
||||||
"\nINCLUDE is.....: %s"
|
"\nINCLUDE is.....: %s"
|
||||||
"\nSEVENBIT is....: %s"
|
"\nGLOBAL is......: %s"
|
||||||
"\nUPPERLOWER is..: %s"
|
"\nSHAREDLIB is...: %s"
|
||||||
|
"\nSWITCH is......: %s"
|
||||||
|
"\nNOTYPE is......: %s"
|
||||||
|
"\nDUP is.........: %s"
|
||||||
|
"\nNOLENGTH is....: %s"
|
||||||
|
"\nRANDOM is......: %s"
|
||||||
|
"\nDEBUG is.......: %s"
|
||||||
"\nlookup function name = %s"
|
"\nlookup function name = %s"
|
||||||
"\nhash function name = %s"
|
"\nhash function name = %s"
|
||||||
"\nword list name = %s"
|
"\nword list name = %s"
|
||||||
@@ -479,25 +491,26 @@ Options::~Options ()
|
|||||||
"\ninitial associated value = %d"
|
"\ninitial associated value = %d"
|
||||||
"\ndelimiters = %s"
|
"\ndelimiters = %s"
|
||||||
"\nnumber of switch statements = %d\n",
|
"\nnumber of switch statements = %d\n",
|
||||||
_option_word & DEBUG ? "enabled" : "disabled",
|
|
||||||
_option_word & TYPE ? "enabled" : "disabled",
|
_option_word & TYPE ? "enabled" : "disabled",
|
||||||
_option_word & RANDOM ? "enabled" : "disabled",
|
_option_word & UPPERLOWER ? "enabled" : "disabled",
|
||||||
_option_word & SWITCH ? "enabled" : "disabled",
|
|
||||||
_option_word & NOLENGTH ? "enabled" : "disabled",
|
|
||||||
_option_word & LENTABLE ? "enabled" : "disabled",
|
|
||||||
_option_word & DUP ? "enabled" : "disabled",
|
|
||||||
_option_word & COMP ? "enabled" : "disabled",
|
|
||||||
_option_word & NOTYPE ? "enabled" : "disabled",
|
|
||||||
_option_word & GLOBAL ? "enabled" : "disabled",
|
|
||||||
_option_word & CONST ? "enabled" : "disabled",
|
|
||||||
_option_word & KRC ? "enabled" : "disabled",
|
_option_word & KRC ? "enabled" : "disabled",
|
||||||
_option_word & C ? "enabled" : "disabled",
|
_option_word & C ? "enabled" : "disabled",
|
||||||
_option_word & ANSIC ? "enabled" : "disabled",
|
_option_word & ANSIC ? "enabled" : "disabled",
|
||||||
_option_word & CPLUSPLUS ? "enabled" : "disabled",
|
_option_word & CPLUSPLUS ? "enabled" : "disabled",
|
||||||
|
_option_word & SEVENBIT ? "enabled" : "disabled",
|
||||||
|
_option_word & LENTABLE ? "enabled" : "disabled",
|
||||||
|
_option_word & COMP ? "enabled" : "disabled",
|
||||||
|
_option_word & CONST ? "enabled" : "disabled",
|
||||||
_option_word & ENUM ? "enabled" : "disabled",
|
_option_word & ENUM ? "enabled" : "disabled",
|
||||||
_option_word & INCLUDE ? "enabled" : "disabled",
|
_option_word & INCLUDE ? "enabled" : "disabled",
|
||||||
_option_word & SEVENBIT ? "enabled" : "disabled",
|
_option_word & GLOBAL ? "enabled" : "disabled",
|
||||||
_option_word & UPPERLOWER ? "enabled" : "disabled",
|
_option_word & SHAREDLIB ? "enabled" : "disabled",
|
||||||
|
_option_word & SWITCH ? "enabled" : "disabled",
|
||||||
|
_option_word & NOTYPE ? "enabled" : "disabled",
|
||||||
|
_option_word & DUP ? "enabled" : "disabled",
|
||||||
|
_option_word & NOLENGTH ? "enabled" : "disabled",
|
||||||
|
_option_word & RANDOM ? "enabled" : "disabled",
|
||||||
|
_option_word & DEBUG ? "enabled" : "disabled",
|
||||||
_function_name, _hash_name, _wordlist_name, _slot_name,
|
_function_name, _hash_name, _wordlist_name, _slot_name,
|
||||||
_initializer_suffix, _asso_iterations, _jump, _size_multiple,
|
_initializer_suffix, _asso_iterations, _jump, _size_multiple,
|
||||||
_initial_asso_value, _delimiters, _total_switches);
|
_initial_asso_value, _delimiters, _total_switches);
|
||||||
@@ -606,7 +619,7 @@ Options::set_delimiters (const char *delimiters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parses the command line Options and sets appropriate flags in option_word. */
|
/* Parses the command line Options and sets appropriate flags in option_word. */
|
||||||
|
|
||||||
static const struct option long_options[] =
|
static const struct option long_options[] =
|
||||||
{
|
{
|
||||||
@@ -668,26 +681,26 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
switch (option_char)
|
switch (option_char)
|
||||||
{
|
{
|
||||||
case 'a': /* Generated code uses the ANSI prototype format. */
|
case 'a': /* Generated code uses the ANSI prototype format. */
|
||||||
break; /* This is now the default. */
|
break; /* This is now the default. */
|
||||||
case 'c': /* Generate strncmp rather than strcmp. */
|
case 'c': /* Generate strncmp rather than strcmp. */
|
||||||
{
|
{
|
||||||
_option_word |= COMP;
|
_option_word |= COMP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'C': /* Make the generated tables readonly (const). */
|
case 'C': /* Make the generated tables readonly (const). */
|
||||||
{
|
{
|
||||||
_option_word |= CONST;
|
_option_word |= CONST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'd': /* Enable debugging option. */
|
case 'd': /* Enable debugging option. */
|
||||||
{
|
{
|
||||||
_option_word |= DEBUG;
|
_option_word |= DEBUG;
|
||||||
fprintf (stderr, "Starting program %s, version %s, with debugging on.\n",
|
fprintf (stderr, "Starting program %s, version %s, with debugging on.\n",
|
||||||
program_name, version_string);
|
program_name, version_string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'D': /* Enable duplicate option. */
|
case 'D': /* Enable duplicate option. */
|
||||||
{
|
{
|
||||||
_option_word |= DUP;
|
_option_word |= DUP;
|
||||||
break;
|
break;
|
||||||
@@ -702,31 +715,31 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
_option_word |= ENUM;
|
_option_word |= ENUM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'f': /* Generate the hash table "fast". */
|
case 'f': /* Generate the hash table "fast". */
|
||||||
break; /* Not needed any more. */
|
break; /* Not needed any more. */
|
||||||
case 'F':
|
case 'F':
|
||||||
{
|
{
|
||||||
_initializer_suffix = /*getopt*/optarg;
|
_initializer_suffix = /*getopt*/optarg;
|
||||||
break;
|
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. */
|
||||||
{
|
{
|
||||||
long_usage (stdout);
|
long_usage (stdout);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
case 'H': /* Sets the name for the hash function */
|
case 'H': /* Sets the name for the hash function. */
|
||||||
{
|
{
|
||||||
_hash_name = /*getopt*/optarg;
|
_hash_name = /*getopt*/optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'i': /* Sets the initial value for the associated values array. */
|
case 'i': /* Sets the initial value for the associated values array. */
|
||||||
{
|
{
|
||||||
if ((_initial_asso_value = atoi (/*getopt*/optarg)) < 0)
|
if ((_initial_asso_value = atoi (/*getopt*/optarg)) < 0)
|
||||||
fprintf (stderr, "Initial value %d should be non-zero, ignoring and continuing.\n", _initial_asso_value);
|
fprintf (stderr, "Initial value %d should be non-zero, ignoring and continuing.\n", _initial_asso_value);
|
||||||
@@ -734,12 +747,12 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
fprintf (stderr, "warning, -r option superceeds -i, ignoring -i option and continuing\n");
|
fprintf (stderr, "warning, -r option superceeds -i, ignoring -i option and continuing\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'I': /* Enable #include statements. */
|
case 'I': /* Enable #include statements. */
|
||||||
{
|
{
|
||||||
_option_word |= INCLUDE;
|
_option_word |= INCLUDE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'j': /* Sets the jump value, must be odd for later algorithms. */
|
case 'j': /* Sets the jump value, must be odd for later algorithms. */
|
||||||
{
|
{
|
||||||
if ((_jump = atoi (/*getopt*/optarg)) < 0)
|
if ((_jump = atoi (/*getopt*/optarg)) < 0)
|
||||||
{
|
{
|
||||||
@@ -751,7 +764,7 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
fprintf (stderr, "Jump value %d should be odd, adding 1 and continuing...\n", _jump++);
|
fprintf (stderr, "Jump value %d should be odd, adding 1 and continuing...\n", _jump++);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'k': /* Sets key positions used for hash function. */
|
case 'k': /* Sets key positions used for hash function. */
|
||||||
{
|
{
|
||||||
_option_word |= POSITIONS;
|
_option_word |= POSITIONS;
|
||||||
const int BAD_VALUE = -2;
|
const int BAD_VALUE = -2;
|
||||||
@@ -809,17 +822,17 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'K': /* Make this the keyname for the keyword component field. */
|
case 'K': /* Make this the keyname for the keyword component field. */
|
||||||
{
|
{
|
||||||
_slot_name = /*getopt*/optarg;
|
_slot_name = /*getopt*/optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'l': /* Create length table to avoid extra string compares. */
|
case 'l': /* Create length table to avoid extra string compares. */
|
||||||
{
|
{
|
||||||
_option_word |= LENTABLE;
|
_option_word |= LENTABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'L': /* Deal with different generated languages. */
|
case 'L': /* Deal with different generated languages. */
|
||||||
{
|
{
|
||||||
_language = NULL;
|
_language = NULL;
|
||||||
set_language (/*getopt*/optarg);
|
set_language (/*getopt*/optarg);
|
||||||
@@ -834,35 +847,35 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'n': /* Don't include the length when computing hash function. */
|
case 'n': /* Don't include the length when computing hash function. */
|
||||||
{
|
{
|
||||||
_option_word |= NOLENGTH;
|
_option_word |= NOLENGTH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'N': /* Make generated lookup function name be optarg */
|
case 'N': /* Make generated lookup function name be optarg. */
|
||||||
{
|
{
|
||||||
_function_name = /*getopt*/optarg;
|
_function_name = /*getopt*/optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'o': /* Order input by frequency of key set occurrence. */
|
case 'o': /* Order input by frequency of key set occurrence. */
|
||||||
break; /* Not needed any more. */
|
break; /* Not needed any more. */
|
||||||
case 'O': /* Optimized choice during collision resolution. */
|
case 'O': /* Optimized choice during collision resolution. */
|
||||||
break; /* Not needed any more. */
|
break; /* Not needed any more. */
|
||||||
case 'p': /* Generated lookup function a pointer instead of int. */
|
case 'p': /* Generated lookup function a pointer instead of int. */
|
||||||
break; /* This is now the default. */
|
break; /* This is now the default. */
|
||||||
case 'P': /* Optimize for position-independent code. */
|
case 'P': /* Optimize for position-independent code. */
|
||||||
{
|
{
|
||||||
_option_word |= SHAREDLIB;
|
_option_word |= SHAREDLIB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'r': /* Utilize randomness to initialize the associated values table. */
|
case 'r': /* Utilize randomness to initialize the associated values table. */
|
||||||
{
|
{
|
||||||
_option_word |= RANDOM;
|
_option_word |= RANDOM;
|
||||||
if (_initial_asso_value != 0)
|
if (_initial_asso_value != 0)
|
||||||
fprintf (stderr, "warning, -r option superceeds -i, disabling -i option and continuing\n");
|
fprintf (stderr, "warning, -r option supersedes -i, disabling -i option and continuing\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's': /* Range of associated values, determines size of final table. */
|
case 's': /* Range of associated values, determines size of final table. */
|
||||||
{
|
{
|
||||||
float numerator;
|
float numerator;
|
||||||
float denominator = 1;
|
float denominator = 1;
|
||||||
@@ -904,7 +917,7 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
fprintf (stderr, "Size multiple %g is extremely small, did you really mean this?! (try '%s --help' for help)\n", _size_multiple, program_name);
|
fprintf (stderr, "Size multiple %g is extremely small, did you really mean this?! (try '%s --help' for help)\n", _size_multiple, program_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'S': /* Generate switch statement output, rather than lookup table. */
|
case 'S': /* Generate switch statement output, rather than lookup table. */
|
||||||
{
|
{
|
||||||
_option_word |= SWITCH;
|
_option_word |= SWITCH;
|
||||||
_total_switches = atoi (/*getopt*/optarg);
|
_total_switches = atoi (/*getopt*/optarg);
|
||||||
@@ -916,17 +929,17 @@ Options::parse_options (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 't': /* Enable the TYPE mode, allowing arbitrary user structures. */
|
case 't': /* Enable the TYPE mode, allowing arbitrary user structures. */
|
||||||
{
|
{
|
||||||
_option_word |= TYPE;
|
_option_word |= TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'T': /* Don't print structure definition. */
|
case 'T': /* Don't print structure definition. */
|
||||||
{
|
{
|
||||||
_option_word |= NOTYPE;
|
_option_word |= NOTYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'v': /* Print out the version and quit. */
|
case 'v': /* Print out the version and quit. */
|
||||||
fprintf (stdout, "GNU gperf %s\n", version_string);
|
fprintf (stdout, "GNU gperf %s\n", version_string);
|
||||||
fprintf (stdout, "Copyright (C) %s Free Software Foundation, Inc.\n\
|
fprintf (stdout, "Copyright (C) %s Free Software Foundation, Inc.\n\
|
||||||
This is free software; see the source for copying conditions. There is NO\n\
|
This is free software; see the source for copying conditions. There is NO\n\
|
||||||
@@ -936,22 +949,22 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
|||||||
fprintf (stdout, "Written by %s and %s.\n",
|
fprintf (stdout, "Written by %s and %s.\n",
|
||||||
"Douglas C. Schmidt", "Bruno Haible");
|
"Douglas C. Schmidt", "Bruno Haible");
|
||||||
exit (0);
|
exit (0);
|
||||||
case 'W': /* Sets the name for the hash table array */
|
case 'W': /* Sets the name for the hash table array. */
|
||||||
{
|
{
|
||||||
_wordlist_name = /*getopt*/optarg;
|
_wordlist_name = /*getopt*/optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'Z': /* Set the class name. */
|
case 'Z': /* Set the class name. */
|
||||||
{
|
{
|
||||||
_class_name = /*getopt*/optarg;
|
_class_name = /*getopt*/optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '7': /* Assume 7-bit characters. */
|
case '7': /* Assume 7-bit characters. */
|
||||||
{
|
{
|
||||||
_option_word |= SEVENBIT;
|
_option_word |= SEVENBIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CHAR_MAX + 1: /* Set the output file name. */
|
case CHAR_MAX + 1: /* Set the output file name. */
|
||||||
{
|
{
|
||||||
_output_file_name = /*getopt*/optarg;
|
_output_file_name = /*getopt*/optarg;
|
||||||
break;
|
break;
|
||||||
|
|||||||
110
src/options.h
110
src/options.h
@@ -32,79 +32,89 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "positions.h"
|
#include "positions.h"
|
||||||
|
|
||||||
/* Enumeration of the possible boolean options. */
|
/* Enumeration of the possible boolean options. */
|
||||||
|
|
||||||
enum Option_Type
|
enum Option_Type
|
||||||
{
|
{
|
||||||
/* Enable debugging (prints diagnostics to stderr). */
|
/* --- Input file interpretation --- */
|
||||||
DEBUG = 1 << 0,
|
|
||||||
|
|
||||||
/* Use the given key positions. */
|
|
||||||
POSITIONS = 1 << 1,
|
|
||||||
|
|
||||||
/* Use all characters in hash function. */
|
|
||||||
ALLCHARS = 1 << 2,
|
|
||||||
|
|
||||||
/* Handle user-defined type structured keyword input. */
|
/* Handle user-defined type structured keyword input. */
|
||||||
TYPE = 1 << 3,
|
TYPE = 1 << 0,
|
||||||
|
|
||||||
/* Randomly initialize the associated values table. */
|
/* Ignore case of ASCII characters. */
|
||||||
RANDOM = 1 << 4,
|
UPPERLOWER = 1 << 1,
|
||||||
|
|
||||||
/* Generate switch output to save space. */
|
/* --- Language for the output code --- */
|
||||||
SWITCH = 1 << 5,
|
|
||||||
|
|
||||||
/* Don't include keyword length in hash computations. */
|
/* Generate K&R C code: no prototypes, no const. */
|
||||||
NOLENGTH = 1 << 6,
|
KRC = 1 << 2,
|
||||||
|
|
||||||
|
/* Generate C code: no prototypes, but const (user can #define it away). */
|
||||||
|
C = 1 << 3,
|
||||||
|
|
||||||
|
/* Generate ISO/ANSI C code: prototypes and const, but no class. */
|
||||||
|
ANSIC = 1 << 4,
|
||||||
|
|
||||||
|
/* Generate C++ code: prototypes, const, class, inline, enum. */
|
||||||
|
CPLUSPLUS = 1 << 5,
|
||||||
|
|
||||||
|
/* --- Details in the output code --- */
|
||||||
|
|
||||||
|
/* Assume 7-bit, not 8-bit, characters. */
|
||||||
|
SEVENBIT = 1 << 6,
|
||||||
|
|
||||||
/* Generate a length table for string comparison. */
|
/* Generate a length table for string comparison. */
|
||||||
LENTABLE = 1 << 7,
|
LENTABLE = 1 << 7,
|
||||||
|
|
||||||
/* Handle duplicate hash values for keywords. */
|
/* Generate strncmp rather than strcmp. */
|
||||||
DUP = 1 << 8,
|
COMP = 1 << 8,
|
||||||
|
|
||||||
|
/* Make the generated tables readonly (const). */
|
||||||
|
CONST = 1 << 9,
|
||||||
|
|
||||||
|
/* Use enum for constants. */
|
||||||
|
ENUM = 1 << 10,
|
||||||
|
|
||||||
|
/* Generate #include statements. */
|
||||||
|
INCLUDE = 1 << 11,
|
||||||
|
|
||||||
|
/* Make the keyword table a global variable. */
|
||||||
|
GLOBAL = 1 << 12,
|
||||||
|
|
||||||
|
/* Optimize for position-independent code. */
|
||||||
|
SHAREDLIB = 1 << 13,
|
||||||
|
|
||||||
|
/* Generate switch output to save space. */
|
||||||
|
SWITCH = 1 << 14,
|
||||||
|
|
||||||
/* Don't include user-defined type definition in output -- it's already
|
/* Don't include user-defined type definition in output -- it's already
|
||||||
defined elsewhere. */
|
defined elsewhere. */
|
||||||
NOTYPE = 1 << 9,
|
NOTYPE = 1 << 15,
|
||||||
|
|
||||||
/* Generate strncmp rather than strcmp. */
|
/* --- Algorithm employed by gperf --- */
|
||||||
COMP = 1 << 10,
|
|
||||||
|
|
||||||
/* Make the keyword table a global variable. */
|
/* Use the given key positions. */
|
||||||
GLOBAL = 1 << 11,
|
POSITIONS = 1 << 16,
|
||||||
|
|
||||||
/* Make the generated tables readonly (const). */
|
/* Use all characters in hash function. */
|
||||||
CONST = 1 << 12,
|
ALLCHARS = 1 << 17,
|
||||||
|
|
||||||
/* Generate K&R C code: no prototypes, no const. */
|
/* Handle duplicate hash values for keywords. */
|
||||||
KRC = 1 << 13,
|
DUP = 1 << 18,
|
||||||
|
|
||||||
/* Generate C code: no prototypes, but const (user can #define it away). */
|
/* Don't include keyword length in hash computations. */
|
||||||
C = 1 << 14,
|
NOLENGTH = 1 << 19,
|
||||||
|
|
||||||
/* Generate ISO/ANSI C code: prototypes and const, but no class. */
|
/* Randomly initialize the associated values table. */
|
||||||
ANSIC = 1 << 15,
|
RANDOM = 1 << 20,
|
||||||
|
|
||||||
/* Generate C++ code: prototypes, const, class, inline, enum. */
|
/* --- Informative output --- */
|
||||||
CPLUSPLUS = 1 << 16,
|
|
||||||
|
|
||||||
/* Use enum for constants. */
|
/* Enable debugging (prints diagnostics to stderr). */
|
||||||
ENUM = 1 << 17,
|
DEBUG = 1 << 21
|
||||||
|
|
||||||
/* Generate #include statements. */
|
|
||||||
INCLUDE = 1 << 18,
|
|
||||||
|
|
||||||
/* Assume 7-bit, not 8-bit, characters. */
|
|
||||||
SEVENBIT = 1 << 19,
|
|
||||||
|
|
||||||
/* Optimize for position-independent code. */
|
|
||||||
SHAREDLIB = 1 << 20,
|
|
||||||
|
|
||||||
/* Ignore case of ASCII characters. */
|
|
||||||
UPPERLOWER = 1 << 21
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Class manager for gperf program Options. */
|
/* Class manager for gperf program Options. */
|
||||||
|
|
||||||
class Options
|
class Options
|
||||||
{
|
{
|
||||||
@@ -193,10 +203,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* Prints program usage to given stream. */
|
/* Prints program usage to given stream. */
|
||||||
void short_usage (FILE * stream) const;
|
static void short_usage (FILE * stream);
|
||||||
|
|
||||||
/* Prints program usage to given stream. */
|
/* Prints program usage to given stream. */
|
||||||
void long_usage (FILE * stream) const;
|
static void long_usage (FILE * stream);
|
||||||
|
|
||||||
/* Records count of command-line arguments. */
|
/* Records count of command-line arguments. */
|
||||||
int _argument_count;
|
int _argument_count;
|
||||||
|
|||||||
Reference in New Issue
Block a user