Deleted Added
sdiff udiff text old ( 58551 ) new ( 67064 )
full compact
1/* Handles parsing the Options provided to the user.
2 Copyright (C) 1989-1998 Free Software Foundation, Inc.
3 written by Douglas C. Schmidt (schmidt@ics.uci.edu)
4
5This file is part of GNU GPERF.
6
7GNU GPERF is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 1, or (at your option)
10any later version.

--- 27 unchanged lines hidden (view full) ---

38static const int DEFAULT_JUMP_VALUE = 5;
39
40/* Default name for generated lookup function. */
41static const char *const DEFAULT_NAME = "in_word_set";
42
43/* Default name for the key component. */
44static const char *const DEFAULT_KEY = "name";
45
46/* Default name for the generated class. */
47static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
48
49/* Default name for generated hash function. */
50static const char *const DEFAULT_HASH_NAME = "hash";
51
52/* Default name for generated hash table array. */
53static const char *const DEFAULT_WORDLIST_NAME = "wordlist";

--- 8 unchanged lines hidden (view full) ---

62int Options::key_pos;
63int Options::jump;
64int Options::initial_asso_value;
65int Options::argument_count;
66int Options::iterations;
67char **Options::argument_vector;
68const char *Options::function_name;
69const char *Options::key_name;
70const char *Options::class_name;
71const char *Options::hash_name;
72const char *Options::wordlist_name;
73const char *Options::delimiters;
74char Options::key_positions[MAX_KEY_POS];
75
76/* Prints program usage to given stream. */
77
78void
79Options::short_usage (FILE * strm)
80{
81 T (Trace t ("Options::short_usage");)
82 fprintf (strm, "Usage: %s [-cCdDef[num]GhHiIjkKlLnNorsStTvWZ7] [input-file]\n"
83 "Try `%s --help' for more information.\n",
84 program_name, program_name);
85}
86
87void
88Options::long_usage (FILE * strm)
89{
90 T (Trace t ("Options::long_usage");)

--- 20 unchanged lines hidden (view full) ---

111 " -L, --language=LANGUAGE-NAME\n"
112 " Generates code in the specified language. Languages\n"
113 " handled are currently C++, ANSI-C, C, and KR-C. The\n"
114 " default is C.\n"
115 "\n"
116 "Details in the output code:\n"
117 " -K, --slot-name=NAME Select name of the keyword component in the keyword\n"
118 " structure.\n"
119 " -H, --hash-fn-name=NAME\n"
120 " Specify name of generated hash function. Default is\n"
121 " `hash'.\n"
122 " -N, --lookup-fn-name=NAME\n"
123 " Specify name of generated lookup function. Default\n"
124 " name is `in_word_set'.\n"
125 " -Z, --class-name=NAME Specify name of generated C++ class. Default name is\n"
126 " `Perfect_Hash'.\n"

--- 90 unchanged lines hidden (view full) ---

217Options::print_options (void)
218{
219 T (Trace t ("Options::print_options");)
220 int i;
221
222 printf ("/* Command-line: ");
223
224 for (i = 0; i < argument_count; i++)
225 printf ("%s ", argument_vector[i]);
226
227 printf (" */");
228}
229
230/* Sorts the key positions *IN REVERSE ORDER!!*
231 This makes further routines more efficient. Especially when generating code.
232 Uses a simple Insertion Sort since the set is probably ordered.
233 Returns 1 if there are no duplicates, 0 otherwise. */
234

--- 26 unchanged lines hidden (view full) ---

261 key_positions[1] = WORD_END;
262 key_positions[2] = EOS;
263 total_keysig_size = 2;
264 delimiters = DEFAULT_DELIMITERS;
265 jump = DEFAULT_JUMP_VALUE;
266 option_word = DEFAULTCHARS | C;
267 function_name = DEFAULT_NAME;
268 key_name = DEFAULT_KEY;
269 hash_name = DEFAULT_HASH_NAME;
270 wordlist_name = DEFAULT_WORDLIST_NAME;
271 class_name = DEFAULT_CLASS_NAME;
272 total_switches = size = 1;
273 initial_asso_value = iterations = 0;
274}
275
276/* Dumps option status when debug is set. */

--- 27 unchanged lines hidden (view full) ---

304 "\nENUM is........: %s"
305 "\nINCLUDE is.....: %s"
306 "\nSEVENBIT is....: %s"
307 "\niterations = %d"
308 "\nlookup function name = %s"
309 "\nhash function name = %s"
310 "\nword list name = %s"
311 "\nkey name = %s"
312 "\njump value = %d"
313 "\nmax associated value = %d"
314 "\ninitial associated value = %d"
315 "\ndelimiters = %s"
316 "\nnumber of switch statements = %d\n",
317 option_word & DEBUG ? "enabled" : "disabled",
318 option_word & ORDER ? "enabled" : "disabled",
319 option_word & TYPE ? "enabled" : "disabled",

--- 12 unchanged lines hidden (view full) ---

332 option_word & C ? "enabled" : "disabled",
333 option_word & ANSIC ? "enabled" : "disabled",
334 option_word & CPLUSPLUS ? "enabled" : "disabled",
335 option_word & ENUM ? "enabled" : "disabled",
336 option_word & INCLUDE ? "enabled" : "disabled",
337 option_word & SEVENBIT ? "enabled" : "disabled",
338 iterations,
339 function_name, hash_name, wordlist_name, key_name,
340 jump, size - 1, initial_asso_value, delimiters, total_switches);
341 if (option_word & ALLCHARS)
342 fprintf (stderr, "all characters are used in the hash function\n");
343
344 fprintf (stderr, "maximum keysig size = %d\nkey positions are: \n",
345 total_keysig_size);
346
347 for (ptr = key_positions; *ptr != EOS; ptr++)
348 if (*ptr == WORD_END)

--- 9 unchanged lines hidden (view full) ---

358/* Parses the command line Options and sets appropriate flags in option_word. */
359
360static const struct option long_options[] =
361{
362 { "delimiters", required_argument, 0, 'e' },
363 { "struct-type", no_argument, 0, 't' },
364 { "language", required_argument, 0, 'L' },
365 { "slot-name", required_argument, 0, 'K' },
366 { "hash-fn-name", required_argument, 0, 'H' },
367 { "lookup-fn-name", required_argument, 0, 'N' },
368 { "class-name", required_argument, 0, 'Z' },
369 { "seven-bit", no_argument, 0, '7' },
370 { "compare-strncmp", no_argument, 0, 'c' },
371 { "readonly-tables", no_argument, 0, 'C' },
372 { "enum", no_argument, 0, 'E' },
373 { "includes", no_argument, 0, 'I' },

--- 24 unchanged lines hidden (view full) ---

398 int option_char;
399
400 program_name = argv[0];
401 argument_count = argc;
402 argument_vector = argv;
403
404 while ((option_char =
405 getopt_long (argument_count, argument_vector,
406 "adcCDe:Ef:gGhH:i:Ij:k:K:lL:nN:oprs:S:tTvW:Z:7",
407 long_options, (int *)0))
408 != -1)
409 {
410 switch (option_char)
411 {
412 case 'a': /* Generated code uses the ANSI prototype format. */
413 break; /* This is now the default. */
414 case 'c': /* Generate strncmp rather than strcmp. */

--- 33 unchanged lines hidden (view full) ---

448 option_word |= FAST;
449 if ((iterations = atoi (/*getopt*/optarg)) < 0)
450 {
451 fprintf (stderr, "iterations value must not be negative, assuming 0\n");
452 iterations = 0;
453 }
454 break;
455 }
456 case 'g': /* Use the ``inline'' keyword for generated sub-routines, ifdef __GNUC__. */
457 break; /* This is now the default. */
458 case 'G': /* Make the keyword table a global variable. */
459 {
460 option_word |= GLOBAL;
461 break;
462 }
463 case 'h': /* Displays a list of helpful Options to the user. */
464 {
465 long_usage (stdout);
466 exit (0);
467 }
468 case 'H': /* Sets the name for the hash function */

--- 200 unchanged lines hidden ---