<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
#
# Generate hash values for keywords
#

eval { use bytes; };

while ( defined($keywd = &lt;STDIN&gt;) ) {
    chomp $keywd;

    ($keywd,$keywdname) = split(/\s+/, $keywd);
    $keywdname = $keywd unless ( $keywdname );

    $l = length($keywd);
    $h = 0;
    for ( $i = 0 ; $i &lt; $l ; $i++ ) {
	$c = ord(substr($keywd,$i,1)) | 0x20;
	$h = ((($h &lt;&lt; 5)|($h &gt;&gt; 27)) ^ $c) &amp; 0xFFFFFFFF;
    }
    if ( $seenhash{$h} ) {
	printf STDERR "$0: hash collision (0x%08x) %s %s\n",
	$h, $keywd, $seenhash{$h};
    }
    $seenhash{$h} = $keywd;
    printf("%-23s equ 0x%08x\n", "hash_${keywdname}", $h);
}
</pre></body></html>