blob: 45d7cedbdc3ca764e15b048dd3f5f286d46d9d34 [file] [log] [blame]
Dominik Riebelingf8eb8c82012-05-29 20:58:57 +02001#!/usr/bin/perl -s
2#
3# __________ __ ___.
4# Open \______ \ ____ ____ | | _\_ |__ _______ ___
5# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8# \/ \/ \/ \/ \/
9#
10
11my $verbose = $v;
12my $reflowed = "";
13my $last = "";
14my $currentfile;
15while(<STDIN>) {
16 chomp $_;
17 $reflowed .= $_;
18 if(/^.{79,}$/) {
19 # collapse all "full" lines
20 }
21 elsif(/^!/) {
22 # collapse lines indicating an error with next one and append a space.
23 $reflowed .= " ";
24 }
25 else {
26 # skip empty lines
27 if(length($reflowed) > 0) {
28 # collapse with previous line if it continues some "area".
29 if($reflowed =~ /^\s*(\]|\[|\\|\)|<)/) {
30 $last .= $reflowed;
31 }
32 else {
33 # find current input file
34 my @inputfile = $last =~ /\(([a-zA-Z_\-\/\.]+\.tex)/g;
35 foreach(@inputfile) {
36 if($verbose) {
37 print "\n";
38 }
39 print "LaTeX processing $_\n";
40 $currentfile = $_;
41 }
42 if($verbose) {
43 print $last;
44 }
45 # check for error
46 if($reflowed =~ /^!\s*(.*)/) {
47 my $l = $reflowed;
48 $l =~ s/^!\s*(.*)l.(\d+) /$2: $1/;
49 print "$currentfile:$l\n";
50 }
51 # restart for next reflowed line
52 $last = $reflowed;
53 }
54 }
55 # restart reflowing.
56 $reflowed = "";
57 }
58}
59if($verbose) {
60 print $last;
61}
62