#!/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 () { #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 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:"