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
|
#!/usr/bin/perl -w
#######################################################################################
# A tool for updating .dtx files with a correspodning checksum counter #
# Copyright (c) 2010, Deyan Ginev, released under the Gnu General Public License (GPL)#
# see http://www.gnu.org/copyleft/gpl.html #
# $URL: https://svn.kwarc.info/repos/stex/trunk/bin/gre-rerun$ #
#######################################################################################
use strict;
use Getopt::Long;
use Pod::Usage;
use File::Spec;
use Cwd qw(abs_path);
####### start of program #######
my ($errlog,$pattern)=@ARGV;
my %rerun_set = ();
open(IN,"<",$errlog);
my ($errvol,$errdir)=File::Spec->splitpath($errlog);
my $currpath=abs_path($errdir);
while (<IN>) {
#Entering, update path
if (/^Entering (.+)$/) {
$currpath.="/$1";
}
#Leaving, update path
elsif (/^Leaving (.+)$/) {
$currpath =~ s/(\/$1)$//;
}
#Matching error, note source
elsif (/$pattern/) {
my ($name) = split(/:/,$_);
($name) = split(/\./,$name);
$rerun_set{$currpath."/".$name.".tex"}=1;
}
}
#Perform rerun of affected sources:
print STDERR scalar(keys %rerun_set)." sources to rerun:\n";
foreach (sort keys %rerun_set) {
my ($vol,$dir,$file) = File::Spec->splitpath( $_ );
print STDERR "Trying $_\n";
$file=~s/\.tex$/.omdoc/;
print STDERR `cd $dir; make $file -B`;
}
close(IN);
__END__
=head1 SYNOPSIS
grep-rerun <errlog filename> <grep pattern>
Purpose:
Given an error log file, generated via the sTeX Makefiles, and an error pattern, fetches and reconverts all sources that suffered this error.
Example:
grep-rerun latex.errlog "Fatal:"
|