Add missing files to menu subdirectory
[syslinux.git] / genhash.pl
blobb1b4cc0e6b71190edb3992e72cf5506850827587
1 #!/usr/bin/perl
3 # Generate hash values for keywords
6 eval { use bytes; };
8 while ( defined($keywd = <STDIN>) ) {
9 chomp $keywd;
11 ($keywd,$keywdname) = split(/\s+/, $keywd);
12 $keywdname = $keywd unless ( $keywdname );
14 $l = length($keywd);
15 $h = 0;
16 for ( $i = 0 ; $i < $l ; $i++ ) {
17 $c = ord(substr($keywd,$i,1)) | 0x20;
18 $h = ((($h << 5)|($h >> 27)) ^ $c) & 0xFFFFFFFF;
20 if ( $seenhash{$h} ) {
21 printf STDERR "$0: hash collision (0x%08x) %s %s\n",
22 $h, $keywd, $seenhash{$h};
24 $seenhash{$h} = $keywd;
25 printf("%-23s equ 0x%08x\n", "hash_${keywdname}", $h);