| 1 | # LaTeX::Driver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Driver module that encapsulates the details of formatting a LaTeX document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package LaTeX::Driver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use 5.008005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | use parent 'Class::Accessor'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | use Cwd; # from PathTools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | use English qw( -no_match_vars ); # standard Perl class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 13 | ▶ | use Exception::Class ( 'LaTeX::Driver::Exception' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | ▶ | use File::Copy; # standard Perl class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | ▶ | use File::Compare; # standard Perl class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | ▶ | use File::Path; # standard Perl class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 13 | ▶ | use File::Slurp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | ▶ | use File::Spec; # from PathTools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | ▶ | use IO::File; # from IO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 13 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | ▶ | use File::pushd; # temporary cwd changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 13 | ▶ | use Capture::Tiny qw(capture); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 13 | ▶ | use Log::Any qw($log); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | Readonly our $DEFAULT_MAXRUNS => 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | our $VERSION = "1.3.1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 13 | __PACKAGE__->mk_accessors( qw( basename basedir basepath options | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | source output tmpdir format timeout stderr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | formatter preprocessors postprocessors _program_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | maxruns extraruns stats texinputs_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | undefined_citations undefined_references | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | labels_changed rerun_required ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 13 | our $DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 13 | our $DEBUGPREFIX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # LaTeX executable paths set at installation time by the Makefile.PL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 13 | our @PROCESSORS = qw(xelatex lualatex pdflatex latex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | our @AUXILLARY_PROGS = qw(bibtex makeindex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 13 | our @POSTPROCESSORS = qw(dvips dvipdfm ps2pdf pdf2ps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | our @PROGRAM_NAMES = (@PROCESSORS, @AUXILLARY_PROGS, @POSTPROCESSORS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | our %program_path = map { ( $_ => $_ ) } @PROGRAM_NAMES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 13 | our @LOGFILE_EXTS = qw( log blg ilg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 13 | our @TMPFILE_EXTS = qw( aux log lot toc bbl ind idx cit cbk ibk ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 13 | our $DEFAULT_TMPDIR = 'latexdrv'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 13 | our $DEFAULT_DOCNAME = 'latexdoc'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # valid output formats and program alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 13 | our $DEFAULT_FORMAT = 'pdf'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 13 | our %FORMATTERS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | dvi => [ 'latex' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ps => [ 'latex', 'dvips' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | postscript => [ 'latex', 'dvips' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | pdf => [ 'xelatex' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'pdf(pdflatex)' => [ 'pdflatex' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 'pdf(xelatex)' => [ 'xelatex' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'pdf(lualatex)' => [ 'lualatex' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'pdf(dvi)' => [ 'latex', 'dvipdfm' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'pdf(ps)' => [ 'latex', 'dvips', 'ps2pdf' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 'ps(pdf)' => [ 'pdflatex', 'pdf2ps' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'ps(pdflatex)' => [ 'pdflatex', 'pdf2ps' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'ps(xelatex)' => [ 'xelatex', 'pdf2ps' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'ps(lualatex)' => [ 'lualatex', 'pdf2ps' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # new(%options) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Constructor for the Latex driver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=35 SCAR=51.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 9 | ▶ | my $options = ref $_[0] ? shift : { @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | my ($volume, $basedir, $basename, $basepath, $orig_ext, $cleanup); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | my ($formatter, @postprocessors); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # Sanity check first - check we're running on a supported OS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 9 | ▶ | $class->throw("not available on $OSNAME") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | if $OSNAME =~ m/ ^ ( MacOS | os2 | VMS ) $ /ix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # Examine the options - we need at least a source to work with and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # it should be a scalar reference or a valid filename. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 9 | my $source = delete $options->{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 9 | ▶ | $class->throw("no source specified") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | unless $source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | ▶ | if (ref $source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $class->throw("source is an invalid reference $source") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | if ref $source ne 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | $source =~ s/ ( [.] tex ) $ //x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | $orig_ext = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | ▶ | $class->throw("source file ${source}.tex does not exist") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $source or -f "$source.tex"
MC/DC0%0/2
-f $source or -f "$source.tex"
-f $source
-f "$source.tex"
Truth table33%1/3
A or B
A= -f $sourceB= -f "$source.tex"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | unless -f $source or -f "${source}.tex"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # Determine how the document is to be processed. Either specified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # explicitly in the format parameter or if an output file is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # specified it is taken from that, or the default is take. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | my $output = $options->{output}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 8 | my $format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $format = lc($options->{format}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 8 | ▶ | if $options->{format}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 8 | ▶ | if ($output and (!ref $output)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$output and not ref $output
MC/DC0%0/2
$output and not ref $output
$output
not ref $output
Truth table33%1/3
A and not(B)
A= $outputB= not ref $output
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($volume, $dir, $file) = File::Spec->splitpath($output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $class->throw("output directory $dir does not exist") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dir and -d $dir
MC/DC0%0/2
$dir and -d $dir
$dir
-d $dir
Truth table0%0/3
A and B
A= $dirB= -d $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | unless $dir and -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ((!$format) and ($file =~ / [.] ( \w+ ) $ /x)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $format and $file =~ / [.] ( \w+ ) $ /x
MC/DC0%0/2
not $format and $file =~ / [.] ( \w+ ) $ /x
not $format
$file =~ / [.] ( \w+ ) $ /x
Truth table0%0/3
not(A) and B
A= not $formatB= $file =~ / [.] ( \w+ ) $ /x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $format = lc($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # There is a formatter and zero or more postprocessors for each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # format; there are also special formats 'pdf(dvi)', 'pdf(ps)' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # 'ps(pdf)' that specify alternate routes to generate the format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | ▶ | $format ||= $DEFAULT_FORMAT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$format ||= $LaTeX::Driver::DEFAULT_FORMAT
MC/DC0%0/2
$format ||= $LaTeX::Driver::DEFAULT_FORMAT
$format
$LaTeX::Driver::DEFAULT_FORMAT
Truth table66%2/3
A ||= B
A= $formatB= $LaTeX::Driver::DEFAULT_FORMAT
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $class->throw("invalid output format: '$format'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 8 | ▶ | unless exists $FORMATTERS{$format}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 7 | ($formatter, @postprocessors) = @{$FORMATTERS{$format}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # discard the parenthesized part of special formats | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | $format =~ s/\(.*\)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # If a temporary directory was specified or the LaTeX source was | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # given as a scalar reference then a temporary directory is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # created and the document source written to that directory or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # copied in if the source is a file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | my $tmpdir = $options->{tmpdir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | ▶ | if ($tmpdir or ref $source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tmpdir or ref $source
MC/DC0%0/2
$tmpdir or ref $source
$tmpdir
ref $source
Truth table33%1/3
A or B
A= $tmpdirB= ref $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $basedir = $class->_setup_tmpdir($tmpdir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if (ref $source) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $basename = $DEFAULT_DOCNAME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $basepath = File::Spec->catfile($basedir, $basename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | write_file($basepath . ".tex", $source) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | or $class->throw("cannot create temporary latex file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ($basename = $source) =~ s{.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $basepath = File::Spec->catfile($basedir, $basename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | copy("$source$orig_ext", "${basepath}.tex") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | or $class->throw("cannot copy $source$orig_ext to temporary directory"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $output ||= "${source}.$format"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$output ||= "$source.$format"
MC/DC0%0/1
$output ||= "$source.$format"
$output
Truth table0%0/2
A
A= $output
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # Otherwise the source was given as a filename, so the base name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # and directory are taken from the source name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 7 | ($volume, $basedir, $basename) = File::Spec->splitpath($source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | $basename =~ s/\.tex$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | ▶ | if ($basedir and $volume) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$basedir and $volume
MC/DC0%0/2
$basedir and $volume
$basedir
$volume
Truth table33%1/3
A and B
A= $basedirB= $volume
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $basedir = File::Spec->catfile($volume, $basedir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 7 | ▶ | $basedir ||= getcwd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$basedir ||= getcwd()
MC/DC0%0/2
$basedir ||= getcwd()
$basedir
getcwd()
Truth table33%1/3
A ||= B
A= $basedirB= getcwd()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 7 | $basedir =~ s{(.)/$}{$1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 7 | $basepath = File::Spec->catfile($basedir, $basename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # Set up a mapping of program name to full pathname. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # This is initialized from the paths detemined at installation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # time, but any specified in the paths option override these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 7 | ▶ | $options->{paths} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options->{"paths"} ||= {}
MC/DC0%0/1
$options->{"paths"} ||= {}
$options->{"paths"}
Truth table50%1/2
A
A= $options->{"paths"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | my $path = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | map { $path->{$_} = $program_path{$_}; } @PROGRAM_NAMES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | map { $path->{$_} = $options->{paths}->{$_}; } keys %{ $options->{paths} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # Set up the texinputs path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 7 | ▶ | my $texinputs_path = $options->{TEXINPUTS} || $options->{texinputs} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$options->{'TEXINPUTS'} || $options->{'texinputs'} || []
$options->{"TEXINPUTS"} or $options->{"texinputs"}
MC/DC50%1/2
$options->{'TEXINPUTS'} || $options->{'texinputs'} || []
$options->{"TEXINPUTS"}
$options->{"texinputs"}
Truth table66%2/3
A or B
A= $options->{"TEXINPUTS"}B= $options->{"texinputs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 7 | ▶ | $texinputs_path = [ split(/:/, $texinputs_path) ] unless ref $texinputs_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # see http://tex.stackexchange.com/questions/149714/149865#149865 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | ▶ | my $texinputs_sep = $OSNAME eq "MSWin32" ? ';' : ':'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # construct and return the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | return $class->SUPER::new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | basename => $basename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | basedir => "$basedir", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | _file_tmp_base => $basedir, # retain ref during object life | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | basepath => $basepath, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | format => $format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | output => $output, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | cleanup => $cleanup || '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | options => $options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | maxruns => $options->{maxruns} || $DEFAULT_MAXRUNS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | extraruns => $options->{extraruns} || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | timeout => $options->{timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | capture_stderr => $options->{capture_stderr} || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | formatter => $formatter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | _program_path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | texinputs_path => join($texinputs_sep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 7 | ▶ | ('.', @{$texinputs_path}, '')), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
$cleanup || ''
$options->{'maxruns'} || $LaTeX::Driver::DEFAULT_MAXRUNS
$options->{'extraruns'} || 0
$options->{'capture_stderr'} || 0
MC/DC0%0/1
$cleanup || ''
$cleanup
MC/DC0%0/2
$options->{'maxruns'} || $LaTeX::Driver::DEFAULT_MAXRUNS
$options->{'maxruns'}
$LaTeX::Driver::DEFAULT_MAXRUNS
MC/DC0%0/1
$options->{'extraruns'} || 0
$options->{'extraruns'}
MC/DC0%0/1
$options->{'capture_stderr'} || 0
$options->{'capture_stderr'}
Truth table50%1/2
A
A= $cleanup
Truth table33%1/3
A || B
A= $options->{'maxruns'}B= $LaTeX::Driver::DEFAULT_MAXRUNS
Truth table50%1/2
A
A= $options->{'extraruns'}
Truth table50%1/2
A
A= $options->{'capture_stderr'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | preprocessors => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | postprocessors => \@postprocessors, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | stats => { runs => {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # run() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # Runs the formatter and other programs to generate the ouptut. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 5 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=11 SCAR=39.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # Check that the file exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | ▶ | $self->throw(sprintf('file %s.tex does not exist', $self->basepath)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | unless -f $self->basepath . '.tex'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # Run any preprocessors (none specified yet). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | map { $self->$_ } @{$self->preprocessors}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # Run LaTeX and friends until an error occurs, the document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # stabilizes, or the maximum number of runs is reached. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | my $maxruns = $self->maxruns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | my $extraruns = $self->extraruns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | RUN: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | foreach my $run (1 .. $maxruns) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 5 | ▶ | if ($self->need_to_run_latex or $extraruns-- > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$self->need_to_run_latex or $extraruns-- > 0
MC/DC0%0/2
$self->need_to_run_latex or $extraruns-- > 0
$self->need_to_run_latex
$extraruns-- > 0
Truth table33%1/3
A or B
A= $self->need_to_run_latexB= $extraruns-- > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | $self->run_latex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | elsif ($self->need_to_run_bibtex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->run_bibtex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | elsif ($self->need_to_run_makeindex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $self->run_makeindex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # Run any postprocessors (e.g.: dvips, ps2pdf, etc). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | foreach my $postproc (@{$self->postprocessors}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $method = $postproc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ($self->can($method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $self->$method(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $method = 'run_' . $postproc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ($self->can($method)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->$method(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $self->throw("cannot find postprocessor $postproc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # Return any output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | $self->copy_to_output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if $self->output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # run_latex() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Run the latex processor (latex or pdflatex depending on what is configured). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 6 | ▶ | sub run_latex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_latex: called CC=17 SCAR=56.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 6 | my $basename = $self->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 6 | my $exitcode = $self->run_command($self->formatter => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | "\\nonstopmode\\def\\TTLATEX{1}\\input{./$basename}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # If an error occurred attempt to extract the interesting lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # from the log file. Even without errors the log file may contain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # interesting warnings indicating that LaTeX or one of its friends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # must be rerun. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $errors = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $logfile = $self->basepath . ".log"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if (my $fh = IO::File->new($logfile, "r")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->reset_latex_required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $matched = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $log->trace($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # TeX errors start with a "!" at the start of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # line, and followed several lines later by a line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # designator of the form "l.nnn" where nnn is the line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # number. We make sure we pick up every /^!/ line, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # and the first /^l.\d/ line after each /^!/ line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if ( $line =~ /^(!.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $errors .= $1 . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $matched = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ▶ | elsif ( $matched && ($line =~ /^(l\.\d.*)/) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$matched and $line =~ /^(l\.\d.*)/
MC/DC0%0/2
$matched and $line =~ /^(l\.\d.*)/
$matched
$line =~ /^(l\.\d.*)/
Truth table0%0/3
A and B
A= $matchedB= $line =~ /^(l\.\d.*)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $errors .= $1 . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $matched = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | elsif ( $line =~ /^Output written on (.*) \((\d+) pages, (\d+) bytes\)./ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my ($ofile, $pages, $bytes) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->{stats}{pages} = $pages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $self->{stats}{bytes} = $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | elsif ( $line =~ /^LaTeX Warning: Reference .*? on page \d+ undefined/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $self->undefined_references(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | elsif ( $line =~ /^LaTeX Warning: Citation .* on page \d+ undefined/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->debug('undefined citations detected'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $self->undefined_citations(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | elsif ( $line =~ /LaTeX Warning: There were undefined references./i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $self->debug('undefined reference detected'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | $self->undefined_references(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | unless $self->undefined_citations; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | elsif ( $line =~ /No file $basename\.(toc|lof|lot)/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $self->debug("missing $1 file"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->undefined_references(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | elsif ( $line =~ /^LaTeX Warning: Label\(s\) may have changed./i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $self->debug('labels have changed'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->labels_changed(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | elsif ( $line =~ /^Package longtable Warning: Table widths have changed[.] Rerun LaTeX[.]/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $self->debug('table widths changed'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->rerun_required(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # A number of packages emit 'rerun' warnings (revtex4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # pdfmark, etc); this regexp catches most of those. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | elsif ( $line =~ /Rerun to get (.*) right/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $self->debug("$1 changed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $self->rerun_required(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $errors = "failed to open $logfile for input"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | if ($exitcode or $errors) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exitcode or $errors
MC/DC0%0/2
$exitcode or $errors
$exitcode
$errors
Truth table0%0/3
A or B
A= $exitcodeB= $errors
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->throw($self->formatter . " exited with errors:\n$errors"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $self->stats->{runs}{formatter}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | sub reset_latex_required { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_latex_required: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $self->rerun_required(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $self->undefined_references(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->labels_changed(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 5 | ▶ | sub need_to_run_latex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
need_to_run_latex: called CC=5 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 5 | my $auxfile = $self->basepath . '.aux'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 5 | ▶ | return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$self->undefined_references or $self->labels_changed or $self->rerun_required or not -f $auxfile
$self->undefined_references or $self->labels_changed or $self->rerun_required
$self->undefined_references or $self->labels_changed
MC/DC0%0/4
$self->undefined_references or $self->labels_changed or $self->rerun_required or not -f $auxfile
$self->undefined_references
$self->labels_changed
$self->rerun_required
not -f $auxfile
Truth table20%1/5
A or B or C or not(D)
A= $self->undefined_referencesB= $self->labels_changedC= $self->rerun_requiredD= not -f $auxfile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | if $self->undefined_references | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | || $self->labels_changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | || $self->rerun_required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | || ! -f $auxfile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # run_bibtex() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | # Run bibtex to generate the bibliography | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # bibtex reads references from the .aux file and writes a .bbl file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # It looks for .bib file in BIBINPUTS and TEXBIB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # It looks for .bst file in BSTINPUTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | sub run_bibtex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_bibtex: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $basename = $self->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $exitcode = $self->run_command(bibtex => $basename, 'BIBINPUTS'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # TODO: extract meaningful error message from .blg file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | $self->throw("bibtex $basename failed ($exitcode)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | if $exitcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # Make a backup of the citations file for future comparison, reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # the undefined citations flag and mark the driver as needing to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # re-run the formatter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $basepath = $self->basepath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | copy("$basepath.cit", "$basepath.cbk"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $self->undefined_citations(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $self->rerun_required(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # $self->need_to_run_bibtex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # LaTeX reports 'Citation ... undefined' if it sees a citation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # (\cite{xxx}, etc) and hasn't read a \bibcite{xxx}{yyy} from the aux | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # file. Those commands are written by parsing the bbl file, but will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # not be seen on the run after bibtex is run as the citations tend to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # come before the \bibliography. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # The latex driver sets undefined_citations if it sees the message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # but we need to look at the .aux file and check whether the \citation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # lines match those seen before the last time bibtex was run. We | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # store the citation commands in a .cit file, this is copied to a cbk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # file by the bibtex method once bibtex has been run. Doing this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # check saves an extra run of bibtex and latex. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub need_to_run_bibtex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
need_to_run_bibtex: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if ($self->undefined_citations) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $auxfile = $self->basepath . '.aux'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $citfile = $self->basepath . '.cit'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $cbkfile = $self->basepath . '.cbk'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | my $auxfh = IO::File->new($auxfile, 'r') or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | my $citfh = IO::File->new($citfile, 'w') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | or $self->throw("failed to open $citfile for output: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | while ( my $line = <$auxfh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | print($citfh $line) if $line =~ /^\\citation/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | undef $auxfh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | undef $citfh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | return if -e $cbkfile and (compare($citfile, $cbkfile) == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $cbkfile and compare($citfile, $cbkfile) == 0
MC/DC0%0/2
-e $cbkfile and compare($citfile, $cbkfile) == 0
-e $cbkfile
compare($citfile, $cbkfile) == 0
Truth table0%0/3
A and B
A= -e $cbkfileB= compare($citfile, $cbkfile) == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # $self->run_makeindex() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # Run makeindex to generate the index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # makeindex has a '-s style' option which specifies the style file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # The environment variable INDEXSTYLE defines the path where the style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # file should be found. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # TODO: sanity check the indexoptions? don't want the caller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # specifying the output index file name as that might screw things up. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | sub run_makeindex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_makeindex: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $basename = $self->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if (my $stylename = $self->options->{indexstyle}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | push @args, '-s', $stylename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | if (my $index_options = $self->options->{indexoptions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | push @args, $index_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $exitcode = $self->run_command(makeindex => [@args, $basename]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # TODO: extract meaningful error message from .ilg file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | $self->throw("makeindex $basename failed ($exitcode)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | if $exitcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # Make a backup of the raw index file that was just processed, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # that we can determine whether makeindex needs to be rerun later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $basepath = $self->basepath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | copy("$basepath.idx", "$basepath.ibk"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $self->rerun_required(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # $self->need_to_run_makeindex() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # Determine whether makeindex needs to be run. Checks that there is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # raw index file and that it differs from the backup file (if that exists). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | sub need_to_run_makeindex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
need_to_run_makeindex: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $basepath = $self->basepath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $raw_index_file = "$basepath.idx"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $backup_file = "$basepath.ibk"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | return unless -e $raw_index_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | return if -e $backup_file and (compare($raw_index_file, $backup_file) == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $backup_file and compare($raw_index_file, $backup_file) == 0
MC/DC0%0/2
-e $backup_file and compare($raw_index_file, $backup_file) == 0
-e $backup_file
compare($raw_index_file, $backup_file) == 0
Truth table0%0/3
A and B
A= -e $backup_fileB= compare($raw_index_file, $backup_file) == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # $self->run_dvips() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # Run dvips to generate PostScript output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | sub run_dvips { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_dvips: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $basename = $self->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $exitstatus = $self->run_command(dvips => [$basename, '-o']); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | $self->throw("dvips $basename failed ($exitstatus)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | if $exitstatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # $self->run_ps2pdf() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # Run ps2pdf to generate PDF from PostScript output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | sub run_ps2pdf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_ps2pdf: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $basename = $self->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $exitstatus = $self->run_command(ps2pdf => ["$basename.ps", "$basename.pdf"]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | $self->throw("ps2pdf $basename failed ($exitstatus)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | if $exitstatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | # $self->run_pdf2ps() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | # Run ps2pdf to generate PostScript from PDF output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | sub run_pdf2ps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_pdf2ps: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my $basename = $self->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $exitstatus = $self->run_command(pdf2ps => ["$basename.pdf", "$basename.ps"]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | $self->throw("pdf2ps $basename failed ($exitstatus)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | if $exitstatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # $self->run_command($progname, $config, $dir, $args, $env) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | # Run a command in the specified directory, setting up the environment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # and allowing for the differences between operating systems. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 6 | ▶ | sub run_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_command: called CC=10 SCAR=26.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 6 | my ($self, $progname, $args, $envvars) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 6 | ▶ | $args = [ $args ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | unless ref $args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # get the full path to the executable for this output format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 6 | ▶ | my $program = $self->program_path($progname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->program_path($progname) || $self->throw("$progname cannot be found, please specify its location")
MC/DC0%0/2
$self->program_path($progname) || $self->throw("$progname cannot be found, please specify its location")
$self->program_path($progname)
$self->throw("$progname cannot be found, please specify its location")
Truth table33%1/3
A || B
A= $self->program_path($progname)B= $self->throw("$progname cannot be found, please specify its location")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | || $self->throw("$progname cannot be found, please specify its location"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 6 | my $dir = $self->basedir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 6 | my $null = File::Spec->devnull(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 6 | my $cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 6 | ▶ | $args ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args ||= ""
MC/DC0%0/1
$args ||= ""
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # Set up localized environment variables in preparation for running the command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # Note that the localized hash slice assignment of %ENV ensures that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # the localization is done at the same block level as the system(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # Even doing something like local($ENV{$_}) = $val for @{$envvars} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # puts the localization in a deeper level block so the previous value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # is restored before the system() call is made. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 6 | ▶ | $envvars ||= "TEXINPUTS"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$envvars ||= "TEXINPUTS"
MC/DC0%0/1
$envvars ||= "TEXINPUTS"
$envvars
Truth table50%1/2
A
A= $envvars
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 6 | ▶ | $envvars = [ $envvars ] unless ref $envvars; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 6 | local(@ENV{@{$envvars}}) = map { $self->texinputs_path } @{$envvars}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 6 | $self->stats->{runs}{$progname}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 6 | $self->debug("running '$program $args'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 6 | my $cwd = pushd($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # Format the command appropriately for our O/S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 6 | my $exit_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | my $exit_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 6 | my ($stdout, $stderr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 6 | ▶ | if ($OSNAME eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $args = join(' ', @$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $cmd = "\"$program\" $args"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | ($stdout, $stderr) = capture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $exit_status = system($cmd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $exit_error = "$!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 6 | ▶ | $args = "'$args'" if $args =~ / \\ /mx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 6 | ▶ | ($stdout, $stderr) = capture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 6 | $exit_status = system($program, @$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 6 | $exit_error = "$!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 6 | ▶ | if ($exit_status == -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 6 | $self->throw( "Failure to start $program: $exit_error" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | $self->{stderr} .= $stderr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if $self->{capture_stderr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | return $exit_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # $self->copy_to_output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | sub copy_to_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_to_output: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | my $output = $self->output or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # construct file name of the generated document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | my $file = $self->basepath . '.' . $self->format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if (ref $output) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $$output = read_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # see if we can rename the generated file to the desired output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # file - this may fail, e.g. across filesystem boundaries (and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | # it's quite common for /tmp to be a separate filesystem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | if (rename($file, $output)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $self->debug("renamed $file to $output"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | elsif (copy($file, $output)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | $self->debug("copied $file to $output"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | $self->throw("failed to copy $file to $output"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # _setup_tmpdir($dirname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # create a temporary directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | sub _setup_tmpdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_tmpdir: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my ($class, $dirname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | $tmp = File::Spec->catdir(File::Spec->tmpdir(), $dirname . 'XXXXXXX') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dirname and $dirname ne 1
MC/DC0%0/2
$dirname and $dirname ne 1
$dirname
$dirname ne 1
Truth table0%0/3
A and B
A= $dirnameB= $dirname ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | if ($dirname and ($dirname ne 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | __PACKAGE__->debug("setting up temporary directory '%s'\n", $dirname || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dirname || ''
MC/DC0%0/1
$dirname || ''
$dirname
Truth table0%0/2
A
A= $dirname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | return File::Temp->newdir(TEMPLATE => $tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | # Destructor (clean up log/temp files) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 7 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=7 SCAR=29.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 7 | local($., $@, $!, $^E, $?); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # Don't log in DESTROY: it has weird interactions with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # global destruction; also: don't use other objects here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 7 | my $what = $self->{cleanup}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 7 | ▶ | return if (not $what or $what eq 'none' or not -d $self->basedir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $what or $what eq "none" or not -d $self->basedir
not $what or $what eq "none"
MC/DC0%0/3
not $what or $what eq "none" or not -d $self->basedir
not $what
$what eq "none"
not -d $self->basedir
Truth table25%1/4
not(A) or B or not(C)
A= not $whatB= $what eq "none"C= not -d $self->basedir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | unlink $self->basepath . ".$_" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | for (@LOGFILE_EXTS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | return if ($what eq 'logfiles'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | unlink $self->basepath . ".$_" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | for (@TMPFILE_EXTS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | # $self->program_path($progname, $optional_value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 6 | ▶ | sub program_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
program_path: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 6 | my $class_or_self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 6 | ▶ | my $href = ref $class_or_self ? $class_or_self->{_program_path} : \%program_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 6 | my $progname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 6 | ▶ | return @_ ? ($href->{$progname} = shift) : $href->{$progname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # throw($error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # Throw an error message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 8 | ▶ | sub throw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 8 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 8 | LaTeX::Driver::Exception->throw( error => join('', @args) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | return; # not needed - but satisfies perlcritic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 6 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=8 SCAR=32.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 6 | my ($self, $string, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 6 | ▶ | my $prefix = ref $self ? $self->{DEBUGPREFIX} : $DEBUGPREFIX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 6 | ▶ | $prefix ||= '[latex] '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$prefix ||= "[latex] "
MC/DC0%0/1
$prefix ||= "[latex] "
$prefix
Truth table50%1/2
A
A= $prefix
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | $log->debugf($prefix . $string, @args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 6 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | if (ref $self ? $self->{DEBUG} : $DEBUG) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | print STDERR $prefix, @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | print STDERR "\n" unless @args and ($args[-1] =~ / \n $ /mx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@args and $args[-1] =~ / \n $ /mx
MC/DC0%0/2
@args and $args[-1] =~ / \n $ /mx
@args
$args[-1] =~ / \n $ /mx
Truth table0%0/3
A and B
A= @argsB= $args[-1] =~ / \n $ /mx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||