2 ## --------------------------------------------------------------------------
4 ## Copyright 1996-2009 the NASM Authors - All rights reserved.
6 ## Redistribution and use in source and binary forms, with or without
7 ## modification, are permitted provided that the following
10 ## * Redistributions of source code must retain the above copyright
11 ## notice, this list of conditions and the following disclaimer.
12 ## * Redistributions in binary form must reproduce the above
13 ## copyright notice, this list of conditions and the following
14 ## disclaimer in the documentation and/or other materials provided
15 ## with the distribution.
17 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18 ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ## --------------------------------------------------------------------------
34 # Perfect Minimal Hash Generator written in Perl, which produces
48 while (defined($l = <STDIN>)) {
50 $l =~ s/\s*(\#.*|)$//;
54 if ($l =~ /^([^=]+)\=([^=]+)$/) {
76 @hashinfo = gen_perfect_hash(\%data);
79 die "$0: no hash found\n";
82 verify_hash_table(\%data, \@hashinfo);
84 ($n, $sv, $f1, $f2, $g) = @hashinfo;
86 print "static int HASHNAME_fg1[$n] =\n";
88 for ($i = 0; $i < $n; $i++) {
89 print "\t", ${$g}[${$f1}[$i]], "\n";
93 print "static int HASHNAME_fg2[$n] =\n";
95 for ($i = 0; $i < $n; $i++) {
96 print "\t", ${$g}[${$f2}[$i]], "\n";
100 print "struct p_hash HASHNAME =\n";
104 print "\tHASHNAME_fg1,\n";
105 print "\tHASHNAME_fg2,\n";