1GPERF(22) FSF GPERF(22)
2
3
4
6 gperf - generate a perfect hash function from a key set
7
9 gperf [OPTION]... [INPUT-FILE]
10
12 GNU 'gperf' generates perfect hash functions.
13
14 If a long option shows an argument as mandatory, then it is mandatory
15 for the equivalent short option also.
16
17 Output file location:
18 --output-file=FILE Write output to specified file.
19
20 The results are written to standard output if no output file is speci‐
21 fied or if it is -.
22
23 Input file interpretation:
24 -e, --delimiters=DELIMITER-LIST
25 Allow user to provide a string containing delimiters used to
26 separate keywords from their attributes. Default is ",".
27
28 -t, --struct-type
29 Allows the user to include a structured type declaration for
30 generated code. Any text before %% is considered part of the
31 type declaration. Key words and additional fields may follow
32 this, one group of fields per line.
33
34 --ignore-case
35 Consider upper and lower case ASCII characters as equivalent.
36 Note that locale dependent case mappings are ignored.
37
38 Language for the output code:
39 -L, --language=LANGUAGE-NAME
40 Generates code in the specified language. Languages handled are
41 currently C++, ANSI-C, C, and KR-C. The default is C.
42
43 Details in the output code:
44 -K, --slot-name=NAME
45 Select name of the keyword component in the keyword structure.
46
47 -F, --initializer-suffix=INITIALIZERS
48 Initializers for additional components in the keyword structure.
49
50 -H, --hash-function-name=NAME
51 Specify name of generated hash function. Default is 'hash'.
52
53 -N, --lookup-function-name=NAME
54 Specify name of generated lookup function. Default name is
55 'in_word_set'.
56
57 -Z, --class-name=NAME
58 Specify name of generated C++ class. Default name is 'Per‐
59 fect_Hash'.
60
61 -7, --seven-bit
62 Assume 7-bit characters.
63
64 -l, --compare-lengths
65 Compare key lengths before trying a string comparison. This is
66 necessary if the keywords contain NUL bytes. It also helps cut
67 down on the number of string comparisons made during the lookup.
68
69 -c, --compare-strncmp
70 Generate comparison code using strncmp rather than strcmp.
71
72 -C, --readonly-tables
73 Make the contents of generated lookup tables constant, i.e.,
74 readonly.
75
76 -E, --enum
77 Define constant values using an enum local to the lookup func‐
78 tion rather than with defines.
79
80 -I, --includes
81 Include the necessary system include file <string.h> at the
82 beginning of the code.
83
84 -G, --global-table
85 Generate the static table of keywords as a static global vari‐
86 able, rather than hiding it inside of the lookup function (which
87 is the default behavior).
88
89 -P, --pic
90 Optimize the generated table for inclusion in shared libraries.
91 This reduces the startup time of programs using a shared library
92 containing the generated code.
93
94 -Q, --string-pool-name=NAME
95 Specify name of string pool generated by option --pic. Default
96 name is 'stringpool'.
97
98 --null-strings
99 Use NULL strings instead of empty strings for empty keyword ta‐
100 ble entries.
101
102 -W, --word-array-name=NAME
103 Specify name of word list array. Default name is 'wordlist'.
104
105 --length-table-name=NAME
106 Specify name of length table array. Default name is 'length‐
107 table'.
108
109 -S, --switch=COUNT
110 Causes the generated C code to use a switch statement scheme,
111 rather than an array lookup table. This can lead to a reduction
112 in both time and space requirements for some keyfiles. The COUNT
113 argument determines how many switch statements are generated. A
114 value of 1 generates 1 switch containing all the elements, a
115 value of 2 generates 2 tables with 1/2 the elements in each ta‐
116 ble, etc. If COUNT is very large, say 1000000, the generated C
117 code does a binary search.
118
119 -T, --omit-struct-type
120 Prevents the transfer of the type declaration to the output
121 file. Use this option if the type is already defined elsewhere.
122
123 Algorithm employed by gperf:
124 -k, --key-positions=KEYS
125 Select the key positions used in the hash function. The allow‐
126 able choices range between 1-255, inclusive. The positions are
127 separated by commas, ranges may be used, and key positions may
128 occur in any order. Also, the meta-character '*' causes the
129 generated hash function to consider ALL key positions, and $
130 indicates the "final character" of a key, e.g., $,1,2,4,6-10.
131
132 -D, --duplicates
133 Handle keywords that hash to duplicate values. This is useful
134 for certain highly redundant keyword sets.
135
136 -m, --multiple-iterations=ITERATIONS
137 Perform multiple choices of the -i and -j values, and choose the
138 best results. This increases the running time by a factor of
139 ITERATIONS but does a good job minimizing the generated table
140 size.
141
142 -i, --initial-asso=N
143 Provide an initial value for the associate values array. Default
144 is 0. Setting this value larger helps inflate the size of the
145 final table.
146
147 -j, --jump=JUMP-VALUE
148 Affects the "jump value", i.e., how far to advance the associ‐
149 ated character value upon collisions. Must be an odd number,
150 default is 5.
151
152 -n, --no-strlen
153 Do not include the length of the keyword when computing the hash
154 function.
155
156 -r, --random
157 Utilizes randomness to initialize the associated values table.
158
159 -s, --size-multiple=N
160 Affects the size of the generated hash table. The numeric argu‐
161 ment N indicates "how many times larger or smaller" the associ‐
162 ated value range should be, in relationship to the number of
163 keys, e.g. a value of 3 means "allow the maximum associated
164 value to be about 3 times larger than the number of input keys".
165 Conversely, a value of 1/3 means "make the maximum associated
166 value about 3 times smaller than the number of input keys". A
167 larger table should decrease the time required for an unsuccess‐
168 ful search, at the expense of extra table space. Default value
169 is 1.
170
171 Informative output:
172 -h, --help
173 Print this message.
174
175 -v, --version
176 Print the gperf version number.
177
178 -d, --debug
179 Enables the debugging option (produces verbose output to the
180 standard error).
181
183 Written by Douglas C. Schmidt and Bruno Haible.
184
186 Report bugs to <bug-gnu-gperf@gnu.org>.
187
189 Copyright © 1989-1998, 2000-2004, 2006 Free Software Foundation, Inc.
190 This is free software; see the source for copying conditions. There is
191 NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
192 PURPOSE.
193
195 The full documentation for gperf is maintained as a Texinfo manual. If
196 the info and gperf programs are properly installed at your site, the
197 command
198
199 info gperf
200
201 should give you access to the complete manual.
202
203
204
205GNU gperf 3.0.2 January 2006 GPERF(22)