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, 2000 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 struct initializer suffix. */
47static const char *const DEFAULT_INITIALIZER_SUFFIX = "";
48
49/* Default name for the generated class. */
50static const char *const DEFAULT_CLASS_NAME = "Perfect_Hash";
51
52/* Default name for generated hash function. */
53static const char *const DEFAULT_HASH_NAME = "hash";
54
55/* Default name for generated hash table array. */
56static const char *const DEFAULT_WORDLIST_NAME = "wordlist";

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

65int Options::key_pos;
66int Options::jump;
67int Options::initial_asso_value;
68int Options::argument_count;
69int Options::iterations;
70char **Options::argument_vector;
71const char *Options::function_name;
72const char *Options::key_name;
73const char *Options::initializer_suffix;
74const char *Options::class_name;
75const char *Options::hash_name;
76const char *Options::wordlist_name;
77const char *Options::delimiters;
78char Options::key_positions[MAX_KEY_POS];
79
80/* Prints program usage to given stream. */
81
82void
83Options::short_usage (FILE * strm)
84{
85 T (Trace t ("Options::short_usage");)
86 fprintf (strm, "Usage: %s [-cCdDef[num]F<initializers>GhH<hashname>i<init>Ijk<keys>K<keyname>lL<language>nN<function name>ors<size>S<switches>tTvW<wordlistname>Z<class name>7] [input-file]\n"
87 "Try `%s --help' for more information.\n",
88 program_name, program_name);
89}
90
91void
92Options::long_usage (FILE * strm)
93{
94 T (Trace t ("Options::long_usage");)

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

115 " -L, --language=LANGUAGE-NAME\n"
116 " Generates code in the specified language. Languages\n"
117 " handled are currently C++, ANSI-C, C, and KR-C. The\n"
118 " default is C.\n"
119 "\n"
120 "Details in the output code:\n"
121 " -K, --slot-name=NAME Select name of the keyword component in the keyword\n"
122 " structure.\n"
123 " -F, --initializer-suffix=INITIALIZERS\n"
124 " Initializers for additional components in the keyword\n"
125 " structure.\n"
126 " -H, --hash-fn-name=NAME\n"
127 " Specify name of generated hash function. Default is\n"
128 " `hash'.\n"
129 " -N, --lookup-fn-name=NAME\n"
130 " Specify name of generated lookup function. Default\n"
131 " name is `in_word_set'.\n"
132 " -Z, --class-name=NAME Specify name of generated C++ class. Default name is\n"
133 " `Perfect_Hash'.\n"

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

224Options::print_options (void)
225{
226 T (Trace t ("Options::print_options");)
227 int i;
228
229 printf ("/* Command-line: ");
230
231 for (i = 0; i < argument_count; i++)
232 {
233 const char *arg = argument_vector[i];
234
235 /* Escape arg if it contains shell metacharacters. */
236 if (*arg == '-')
237 {
238 putchar (*arg);
239 arg++;
240 if (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z')
241 {
242 putchar (*arg);
243 arg++;
244 }
245 }
246 if (strpbrk (arg, "\t\n !\"#$&'()*;<>?[\\]`{|}~") != NULL)
247 {
248 if (strchr (arg, '\'') != NULL)
249 {
250 putchar ('"');
251 for (; *arg; arg++)
252 {
253 if (*arg == '\"' || *arg == '\\' || *arg == '$')
254 putchar ('\\');
255 putchar (*arg);
256 }
257 putchar ('"');
258 }
259 else
260 {
261 putchar ('\'');
262 for (; *arg; arg++)
263 {
264 if (*arg == '\\')
265 putchar ('\\');
266 putchar (*arg);
267 }
268 putchar ('\'');
269 }
270 }
271 else
272 printf ("%s", arg);
273
274 printf (" ");
275 }
276
277 printf (" */");
278}
279
280/* Sorts the key positions *IN REVERSE ORDER!!*
281 This makes further routines more efficient. Especially when generating code.
282 Uses a simple Insertion Sort since the set is probably ordered.
283 Returns 1 if there are no duplicates, 0 otherwise. */
284

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

311 key_positions[1] = WORD_END;
312 key_positions[2] = EOS;
313 total_keysig_size = 2;
314 delimiters = DEFAULT_DELIMITERS;
315 jump = DEFAULT_JUMP_VALUE;
316 option_word = DEFAULTCHARS | C;
317 function_name = DEFAULT_NAME;
318 key_name = DEFAULT_KEY;
319 initializer_suffix = DEFAULT_INITIALIZER_SUFFIX;
320 hash_name = DEFAULT_HASH_NAME;
321 wordlist_name = DEFAULT_WORDLIST_NAME;
322 class_name = DEFAULT_CLASS_NAME;
323 total_switches = size = 1;
324 initial_asso_value = iterations = 0;
325}
326
327/* Dumps option status when debug is set. */

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

355 "\nENUM is........: %s"
356 "\nINCLUDE is.....: %s"
357 "\nSEVENBIT is....: %s"
358 "\niterations = %d"
359 "\nlookup function name = %s"
360 "\nhash function name = %s"
361 "\nword list name = %s"
362 "\nkey name = %s"
363 "\ninitializer suffix = %s"
364 "\njump value = %d"
365 "\nmax associated value = %d"
366 "\ninitial associated value = %d"
367 "\ndelimiters = %s"
368 "\nnumber of switch statements = %d\n",
369 option_word & DEBUG ? "enabled" : "disabled",
370 option_word & ORDER ? "enabled" : "disabled",
371 option_word & TYPE ? "enabled" : "disabled",

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

384 option_word & C ? "enabled" : "disabled",
385 option_word & ANSIC ? "enabled" : "disabled",
386 option_word & CPLUSPLUS ? "enabled" : "disabled",
387 option_word & ENUM ? "enabled" : "disabled",
388 option_word & INCLUDE ? "enabled" : "disabled",
389 option_word & SEVENBIT ? "enabled" : "disabled",
390 iterations,
391 function_name, hash_name, wordlist_name, key_name,
392 initializer_suffix, jump, size - 1, initial_asso_value,
393 delimiters, total_switches);
394 if (option_word & ALLCHARS)
395 fprintf (stderr, "all characters are used in the hash function\n");
396
397 fprintf (stderr, "maximum keysig size = %d\nkey positions are: \n",
398 total_keysig_size);
399
400 for (ptr = key_positions; *ptr != EOS; ptr++)
401 if (*ptr == WORD_END)

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

411/* Parses the command line Options and sets appropriate flags in option_word. */
412
413static const struct option long_options[] =
414{
415 { "delimiters", required_argument, 0, 'e' },
416 { "struct-type", no_argument, 0, 't' },
417 { "language", required_argument, 0, 'L' },
418 { "slot-name", required_argument, 0, 'K' },
419 { "initializer-suffix", required_argument, 0, 'F' },
420 { "hash-fn-name", required_argument, 0, 'H' },
421 { "lookup-fn-name", required_argument, 0, 'N' },
422 { "class-name", required_argument, 0, 'Z' },
423 { "seven-bit", no_argument, 0, '7' },
424 { "compare-strncmp", no_argument, 0, 'c' },
425 { "readonly-tables", no_argument, 0, 'C' },
426 { "enum", no_argument, 0, 'E' },
427 { "includes", no_argument, 0, 'I' },

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

452 int option_char;
453
454 program_name = argv[0];
455 argument_count = argc;
456 argument_vector = argv;
457
458 while ((option_char =
459 getopt_long (argument_count, argument_vector,
460 "adcCDe:Ef:F:gGhH:i:Ij:k:K:lL:nN:oprs:S:tTvW:Z:7",
461 long_options, (int *)0))
462 != -1)
463 {
464 switch (option_char)
465 {
466 case 'a': /* Generated code uses the ANSI prototype format. */
467 break; /* This is now the default. */
468 case 'c': /* Generate strncmp rather than strcmp. */

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

502 option_word |= FAST;
503 if ((iterations = atoi (/*getopt*/optarg)) < 0)
504 {
505 fprintf (stderr, "iterations value must not be negative, assuming 0\n");
506 iterations = 0;
507 }
508 break;
509 }
510 case 'F':
511 {
512 initializer_suffix = /*getopt*/optarg;
513 break;
514 }
515 case 'g': /* Use the ``inline'' keyword for generated sub-routines, ifdef __GNUC__. */
516 break; /* This is now the default. */
517 case 'G': /* Make the keyword table a global variable. */
518 {
519 option_word |= GLOBAL;
520 break;
521 }
522 case 'h': /* Displays a list of helpful Options to the user. */
523 {
524 long_usage (stdout);
525 exit (0);
526 }
527 case 'H': /* Sets the name for the hash function */

--- 200 unchanged lines hidden ---