root/core/genhash.pl

Revision b536209dfb7bd50c37061735fe10d2c19a97d26d, 0.6 KB (checked in by H. Peter Anvin <hpa@…>, 4 years ago)

Move files out of root into core, dos, and utils

Move source files out of the root directory; the root is a mess and
has become virtually unmaintainable. The Syslinux core now lives in
core/; the Linux and generic utilities has moved into utils/, and
copybs.com has moved into dos/; it had to go somewhere, and it seemed
as good a place as any.

  • Property mode set to 100755
Line 
1#!/usr/bin/perl
2#
3# Generate hash values for keywords
4#
5
6eval { use bytes; };
7
8while ( defined($keywd = <STDIN>) ) {
9    chomp $keywd;
10
11    ($keywd,$keywdname) = split(/\s+/, $keywd);
12    $keywdname = $keywd unless ( $keywdname );
13
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;
19    }
20    if ( $seenhash{$h} ) {
21        printf STDERR "$0: hash collision (0x%08x) %s %s\n",
22        $h, $keywd, $seenhash{$h};
23    }
24    $seenhash{$h} = $keywd;
25    printf("%-23s equ 0x%08x\n", "hash_${keywdname}", $h);
26}
Note: See TracBrowser for help on using the browser.