aboutsummaryrefslogtreecommitdiffstats
path: root/genhash.pl
diff options
context:
space:
mode:
authorhpa <hpa>2002-04-27 01:58:51 +0000
committerhpa <hpa>2002-04-27 01:58:51 +0000
commit3dbbdb92ddfa677fa6a9bb3700f65a3d97a9815c (patch)
tree1b80a33be0448662347df4cd5c0268766450dd8d /genhash.pl
parent8e7b2134e3dbb5bf2fe1a9f0bc4d334f4e14df53 (diff)
downloadsyslinux-elf-3dbbdb92ddfa677fa6a9bb3700f65a3d97a9815c.tar.gz
syslinux-elf-3dbbdb92ddfa677fa6a9bb3700f65a3d97a9815c.tar.xz
syslinux-elf-3dbbdb92ddfa677fa6a9bb3700f65a3d97a9815c.zip
Generate hashes for the new parser
Diffstat (limited to 'genhash.pl')
-rwxr-xr-xgenhash.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/genhash.pl b/genhash.pl
new file mode 100755
index 00000000..a0d9bc21
--- /dev/null
+++ b/genhash.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+#
+# Generate hash values for keywords
+#
+
+while ( defined($keywd = <STDIN>) ) {
+ chomp $keywd;
+
+ $l = length($keywd);
+ $h = 0;
+ for ( $i = 0 ; $i < $l ; $i++ ) {
+ $c = ord(substr($keywd,$i,1)) | 0x20;
+ $h = ((($h << 5)|($h >> 27)) ^ $c) & 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_\L${keywd}\E", $h);
+}