Add regression verification script
[ctsim.git] / doc / maphhc.pl
1 #!/usr/bin/perl -Tw
2
3 my $mapfile = "../src/ctsim-map.h";
4 my $hhcfile = "ctsim.hhc";
5 my $newhhc = "ctsim-new.hhc";
6 my %map;
7
8 open (MAP, $mapfile) || print "Unable to open map file $mapfile";
9 while (<MAP>) {
10     m|^\W*#define\W+IDH_(\w+)\W+(\w+)|;
11     $map{$1} = $2 if ($1 && $2);
12 }
13 close (MAP);
14
15 open(HHC,$hhcfile) || print "Unable to open existing hhc file $hhcfile";
16 open(NEWHHC,"> $newhhc") || print "Unable to open new hhc file $newhhc";
17 while (<HHC>) {
18     $line=$_;
19     if ($line =~ m|(.*)\#IDH_([A-Za-z_]+)(.*)|) {
20         my $varname=$2;
21         print NEWHHC  $1 . $3 . "\n";
22         if ($map{$2}) {
23             print NEWHHC "<param name=\"ID\" value=\"$map{$2}\">\n";
24         } else {
25             print "Warning: unable to find IDH_$varname in $mapfile";
26         }
27     } else {
28         print NEWHHC $line;
29     }
30
31 }
32
33 close(HHC);
34 close(NEWHHC);
35
36 unlink($hhcfile);
37 rename($newhhc,$hhcfile);
38
39 exit(0);