tokhash: allow a bit smarter pattern matching
authorH. Peter Anvin <hpa@zytor.com>
Mon, 24 Sep 2007 17:50:23 +0000 (10:50 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 24 Sep 2007 17:50:23 +0000 (10:50 -0700)
Allow constants to match only part of the token string.

tokhash.pl

index a63e55f..f45d07d 100755 (executable)
@@ -101,6 +101,18 @@ while (defined($line = <TD>)) {
        $tokens{$token} = scalar @tokendata;
        
        $data = $pattern;
+       if ($data =~ /^(.*)\{(.*)\}(.*)$/) {
+           my $head = $1, $tail = $3;
+           my $px = $2;
+           
+           $px =~ s/\*/(.*)/g;
+           if ($token =~ /$px/i) {
+               $data = $head."\U$1".$tail;
+           } else {
+               die "$0: token $token doesn't match $px\n";
+           }
+       }
+
        $data =~ s/\*/\U$token/g;
 
        push(@tokendata, "\"$token\", $data");