3 use File
::Temp qw
/ tempdir /;
6 die "$prog <code file> <error string> [optional command]\n" if ($#ARGV < 0);
7 my $file = shift @ARGV;
8 die "$prog: [error] cannot read file $file\n" if (! -r
$file);
10 my $magic = shift @ARGV;
11 die "$prog: [error] no error string specified\n" if (! defined $magic);
13 # Create a backup of the file.
14 my $dir = tempdir
( CLEANUP
=> 1 );
15 print "$prog: created temporary directory '$dir'\n";
16 my $srcFile = "$dir/$file";
20 my $scriptFile = "$dir/script";
21 open(OUT
, ">$scriptFile") or die "$prog: cannot create '$scriptFile'\n";
22 my $reduceOut = "$dir/reduceOut";
25 if (scalar(@ARGV) > 0) { $command = \
@ARGV; }
27 my $compiler = "clang";
28 $command = [$compiler, "-fsyntax-only", "-Wfatal-errors", "-Wno-deprecated-declarations", "-Wimplicit-function-declaration"];
30 push @
$command, $srcFile;
31 my $commandStr = "@$command";
39 my \$command = "$commandStr > $reduceOut 2>&1";
41 open(IN, "$reduceOut") or exit(\$BAD);
44 if (/$magic/) { exit \$GOOD; }
49 `chmod +x $scriptFile`;
51 print "$prog: starting reduction\n";
54 system("multidelta -level=$level $scriptFile $srcFile");
57 for (my $i = 1 ; $i <= 5; $i++) {
58 foreach my $level (0,0,1,1,2,2,10) {
63 # Copy the final file.
64 `cp $srcFile $file.reduced`;
65 print "$prog: generated '$file.reduced";