>>Date: Tue, 7 Nov 2000 18:50:20 +0100
>>From: Jan Goebel <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: Re: log file, how to limit output
>>Mail-Followup-To: Jan Goebel <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED]
>>User-Agent: Mutt/1.2.5i
>>
>>On Tue, 07 Nov 2000, Jean-Pierre.Chretien wrote:
>>
>>> With LyX, the « Edit->Go to error » function allows to get from one error
>>> message to the other without going into the log file.
>>
>>But sometimes the location of the error box isn't very informativ :(
>>
>>> 
>>> With latex I do inline filtering wih a perl script which
>>> kepps track of the errors and warnings.
>>
>>Nice, maybe you can make this available?

Sure, you'll have to hack it a bit because it
runs the required latex passes to complete the compilation.
You may run it as is on the tex file of the temporary.

Please keep me posted personnaly if you find bugs...


-- 
Jean-Pierre
#!/usr/local/bin/perl
#


if ($ARGV[0] eq "-h" || $ARGV[0] eq "") {
usage; exit;
}

$log=0;
$log=1,shift @ARGV if ($ARGV[0]=~m/^\-l|\-log/);
 
BOUCLE:     while (@ARGV) {
        $ARG = shift @ARGV;
        $allok=1;
       ($rac,$suf)=($ARG=~m/(.*?)\.(tex)$/m);
        if ($suf ne "tex") {
        print "$ARG: tex extension needed...\n";
        next BOUCLE;
      }

        $passe1=`latex '\\nonstopmode{\\input{$rac}}`;
        $lastpasse=$passe1;#($temps)=($lastpasse=~m/([0-9]+\.[0-9]+)u 
[0-9]+\.[0-9]+s/sg);
        print "$ARG: first pass...\n" unless ($log);

#       print "\n******** Passe 1 ************\n$passe1\n\n";
        if ($passe1=~m/LaTeX Warning\: There were undefined references\./) {
          $passe1=`bibtex $rac; latex '\\nonstopmode{\\input{$rac}}`;
        $lastpasse=$passe1; 
          print "$ARG: bibTeX pass...\n" unless ($log);

#        print "\n******** Passe 2 ************\n$passe1\n\n";
        }

        if ($passe1=~m/LaTeX Warning\: Label\(s\) may have changed\. Rerun to get 
cross\-references right\./) {

        $passe2=`latex '\\nonstopmode{\\input{$rac}}`;
#        print "\n******** Passe 2 ************\n$passe2\n\n";
        $lastpasse=$passe2;
       print "$ARG: second pass...\n" unless ($log);

      }
        if ($passe2=~m/LaTeX Warning\: Label\(s\) may have changed\. Rerun to get 
cross\-references right\./) {
        $passe3=`latex '\\nonstopmode{\\input{$rac}}`;
#        print "\n******** Passe 3 ************\n$passe2\n\n";
        $lastpasse=$passe2;
       print "$ARG: third pass...\n" unless ($log);

      }
        if (($lastpasse=~m/LaTeX Warning\: There were undefined references\./)) {
        print "$ARG: undefined bibliographic reference(s) after bibtex,
check citations:\n" unless ($log);
        (@messages)=($lastpasse=~m/\nLaTeX Warning\: (Citation.*?)\n/gs);
        print join('
',@messages),"\n\n";
        $allok=0;
} 

        if (`grep '^! ' $rac.log`) {
       print "$ARG: remaining errors, check $rac.log:\n" unless ($log);
       (@messageslat)=($lastpasse=~m/\n(! .*?\n.*?\n)/gs);
        print join('
',@messageslat),"\n\n";
#        print $lastpasse,"\n";
        $allok=0;
     }
unless ($log) {
       print "$ARG: errorless compilation.\n" if ($allok);
     
        undef  @warnings;     
        (@warnings)=($lastpasse=~m/\nLaTeX Warning\: (.*?)\n/gs);
        print "\nRemaining warnings:\n",join('
',@warnings),"\n\n" if ($allok && @warnings);
     }
print "$lastpasse" if ($log);      
    }

sub usage {
    print "Usage: latfin [-h(elp)|-l(og)]  <file1> <file2> ... 
(* convention admitted, e.g. latfin *.tex)
Extension .tex required.
Compiles a latex document w/ necessary passes.
Keeps track of warmning and errors.
latfin -l(og) toto.tex : standard log instead.
";
}


Reply via email to