File: expand.pl

package info (click to toggle)
ns2 2.35%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,864 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 818; awk: 525; csh: 355
file content (37 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (8)
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

sub usage {
    die("usage: $0 <mainfile> <toolname>");
}

if ($#ARGV != 1) {
    &usage;
}

$mainfile = $ARGV[0];
$toolname = $ARGV[1];
open(OF, ">$toolname");
print "expanding $mainfile to $toolname ... \n";

# print header
open(H, "head.tcl");
while (<H>) {
    s/TOOLNAME/$toolname/;
    print OF;
}
close(H);

$tclsh = $ENV{'TCLSH'};
print "using tclsh=$tclsh\n";
open(S, "$tclsh tcl-expand.tcl $mainfile |");

while (<S>) {
    if (!(/^\s*#/ || /^\s*$/)) {
        print OF;
        $n++;
        ($n % 200 == 0) && print("*");
    }
}
print "\ntotal $n lines\n";
close(S);
close(OF);