summaryrefslogtreecommitdiff
path: root/mad/p55
blob: 20b879bbd263b2be7543863d3d5e66c06a00bce8 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl

while (@ARGV and $ARGV[0] =~ /^-/) {
    my $switch = shift;
    if ($switch eq '-Y') {
        $YAML = '-Y ';
    }
    else {
        die "Unrecognized switch: -$switch";
    }
}

my $file = shift;
my $infile = $file;

unlink "$file.msg";
my $top = "/home/larry/src/p55";

my $text;
open(FILE, $file) or die "Can't open $file: $!\n";
{
    local $/;
    $text = <FILE>;
}
close FILE;
my $T;
$switches = $1 if $text =~ /^#!.*?\s(-.*)/;
$switches =~ s/\s+-[-*].*//;
$switches =~ s/\s+#.*//;

#if ($text =~ s/\bexit\b/DUMMYEXIT/g) {
#    $infile = "$file.tmp";
#    open FILE, ">$infile";
#    print FILE $text;
#    close FILE;
#}

unlink "$file.xml", "$file.msg", "$file.err", "$file.diff", "$file.p5";
print "PERL_XMLDUMP='$file.xml' $top/perl $switches -I lib $infile 2>$file.err\n";
system "PERL_XMLDUMP='$file.xml' $top/perl $switches -I lib $infile 2>$file.err";

if ($?) {
    print "Exit status $?\n";
    system "cat $file.err";
    exit 1;
}

if (not -s "$file.xml") {
    die "Didn't produce an xml file!?!\n"
}

if ($YAML) {
    system "$top/nomad -Y $file.xml";
    exit;
}

system "$top/nomad $file.xml >$file.p5 2>$file.msg";

if ($?) {
    print "Oops!\n" unless -s "$file.msg";
    system "cat $file.msg";
    exit 1;
}

system "diff -u $file $file.p5 >$file.diff";
if (-s "$file.diff") {
    system "cat $file.diff";
    exit 1;
}