0x0
 1¤    #!/usr/bin/perl
# Debian required shebang above
# Original shebang below
# #!/usr/bin/env perl
# This is texloganalyser, for parsing of TeX logs
# Copyright (c) 2006-2020 Thomas van Oudenhove
# All rights reserved

# README - important notice:
# you should feed the first line with the path of your Perl executable
# (on *nix systems, the output of 'which perl')
#
# (this program works at least with perl 5.8.8)
# Getopt::Long MUST be installed on your system for this program to work

# License:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

use warnings;
use strict;
use Getopt::Long;
Getopt::Long::Configure ("bundling");

my $version = "0.11";
my $copyright = "2006-2020";
my $opt = {
    help => '',
    version => '',
    last => '',
    a => '',
    h => '',
    o => '',
    u => '',
    v => '',
    c => '',
    p => '',
    f => '',
    w => '',
    e => '',
    i => '',
    s => '',
    r => '',
    t => '',
    n => '',
};

GetOptions(
    'help' => \$opt->{help},
    'version' => \$opt->{version},
    'last' => \$opt->{last},
    'a' => \$opt->{a},
    'c' => \$opt->{c},
    'h' => \$opt->{h},
    'o' => \$opt->{o},
    'u' => \$opt->{u},
    'v' => \$opt->{v},
    'p' => \$opt->{p},
    'f' => \$opt->{f},
    'w' => \$opt->{w},
    'e' => \$opt->{e},
    'i' => \$opt->{i},
    't' => \$opt->{t},
    's' => \$opt->{s},
    'r' => \$opt->{r},
    'n' => \$opt->{n},
);

my $abstract = {
    warnings => 0,
    badboxes => 0,
};

my $texlog = $ARGV[-1];

die "Usage: $0 ".options()." <TeX log>\n"
    if (not defined $texlog and
        (not $opt->{help} and not $opt->{version}));

if ($opt->{help}) {
    printhelp();
    exit();
}

if ($opt->{version}) {
    printversion();
    exit();
}

analyze();

sub analyze {
    my $line;
    my ($cbox, $chead);
    my $output;
    my $test = 0;
    my $png = 0;

    open my $source, "<", $texlog;
    while (defined ($line = <$source>)) {
        undef $output;
        # default: display summary
        summary($line);
        #          and page numbers ('n' option)
        my $pn = pagenumber($line);
        print '['.$pn.']' if ($opt->{n} and $pn);
        $png = $pn if $pn;

        if ($opt->{e}) {
            if ($line =~ m/Here is how much/) {
                $test = 1;
                $output = "\n";
            }
            $output .= $line if $test;
        }
        # look for boxes warnings
        if ($opt->{c} and $opt->{o} and $opt->{h}) {
            if ($line =~ m/\\hbox/ and $line =~ m/Overfull/) {
                $line =~ m/^Overfull \\hbox \((\d+\.\d+)pt too wide\) .*$/;
                $cbox->{$1} = 'Page '.$png.': '.$line;
                $chead = 'Overfull hboxes classified:';
            }
        } elsif ($opt->{c} and $opt->{u} and $opt->{h}) {
            if ($line =~ m/\\hbox/ and $line =~ m/Underfull/) {
                $line =~ m/^Underfull \\