File: maphhc.pl

package info (click to toggle)
ctsim 4.5.2-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 6,536 kB
  • ctags: 3,720
  • sloc: cpp: 26,768; sh: 3,691; ansic: 1,254; perl: 296; makefile: 263
file content (39 lines) | stat: -rwxr-xr-x 850 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl -Tw

my $mapfile = "../src/ctsim-map.h";
my $hhcfile = "ctsim.hhc";
my $newhhc = "ctsim-new.hhc";
my %map;

open (MAP, $mapfile) || print "Unable to open map file $mapfile";
while (<MAP>) {
    m|^\W*#define\W+IDH_(\w+)\W+(\w+)|;
    $map{$1} = $2 if ($1 && $2);
}
close (MAP);

open(HHC,$hhcfile) || print "Unable to open existing hhc file $hhcfile";
open(NEWHHC,"> $newhhc") || print "Unable to open new hhc file $newhhc";
while (<HHC>) {
    $line=$_;
    if ($line =~ m|(.*)\#IDH_([A-Za-z_]+)(.*)|) {
	my $varname=$2;
	print NEWHHC  $1 . $3 . "\n";
	if ($map{$2}) {
	    print NEWHHC "<param name=\"ID\" value=\"$map{$2}\">\n";
	} else {
	    print "Warning: unable to find IDH_$varname in $mapfile";
	}
    } else {
	print NEWHHC $line;
    }

}

close(HHC);
close(NEWHHC);

unlink($hhcfile);
rename($newhhc,$hhcfile);

exit(0);