Annotation of /tags/mkinitrd-6_3_1/isolinux/genhash.pl
Parent Directory | Revision Log
Revision 1143 -
(hide annotations)
(download)
Thu Aug 19 12:44:27 2010 UTC (14 years, 1 month ago) by niro
File MIME type: text/plain
File size: 606 byte(s)
Thu Aug 19 12:44:27 2010 UTC (14 years, 1 month ago) by niro
File MIME type: text/plain
File size: 606 byte(s)
tagged 'mkinitrd-6_3_1'
1 | niro | 532 | #!/usr/bin/perl |
2 | # | ||
3 | # Generate hash values for keywords | ||
4 | # | ||
5 | |||
6 | eval { use bytes; }; | ||
7 | |||
8 | while ( defined($keywd = <STDIN>) ) { | ||
9 | chomp $keywd; | ||
10 | niro | 1133 | |
11 | niro | 532 | ($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 | } |
Properties
Name | Value |
---|---|
svn:executable | * |