lib/LaTeXML/Common/Error.pm

filter: Statementstmt 12.7% 61 / 479 Branchbran 0.0% 0 / 272 Conditioncond 0.0% 0 / 237 MC/DCmcdc 0.0% 0 / 132 Subroutinesub 19.6% 11 / 56 Podpod 47.3% 18 / 38 totaltotal 7.4% 90 / 1214 CC 222 SCAR 52.4
CC
222
Cov
6%
generateMessage
930.0
Fatal
272.0
objectStack
240.0
CRAP 188.6
« lib/LaTeXML/Core/State.pm ↑ Summary lib/LaTeXML/Util/Pathname.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Common::Error | #
3 # | Error handler | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> #_# | #
10 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
11 # \=========================================================ooo==U==ooo=/ #
12 package LaTeXML::Common::Error;
13 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 32 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 32 ▶use LaTeXML::Common::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 32 ▶use LaTeXML::Util::Pathname;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 32 ▶use LaTeXML::Core::Token qw(T_CS);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 32 ▶use Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 32 ▶use Term::ANSIColor qw(colored colorstrip);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 32 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 32 our @EXPORT = (
24 qw(&SetVerbosity),
25 # Managing STDERR and Logfile messages
26 qw(&UseSTDERR &UseLog),
27 # Error Reporting
28 qw(&Fatal &Error &Warn &Info),
29 # General messages
30 qw(&Note &NoteSTDERR &NoteLog),
31 # Progress Spinner
32 qw(&ProgressSpinup &ProgressSpindown &ProgressStep),
33 # Debugging messages
34 qw(&DebuggableFeature &Debug &CheckDebuggable),
35 # Colored-logging related functions
36 qw(&colorizeString),
37 # stateless message generation
38 qw(&generateMessage),
39 # Status management
40 qw(&MergeStatus),
41 # Run time reporting
42 qw(&StartTime &RunTime),
43 );
44  
45 32 our $VERBOSITY = 0;
46 32 our $IS_TERMINAL = undef;
47 32 our $USE_STDERR = undef;
48  
49 sub SetVerbosity {
50 0 ▶ return $VERBOSITY = $_[0] || 0; }
Subroutine SetVerbosity: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[0] || 0
l!l
00
MC/DC0%0/1
$_[0] || 0
$_[0]
Truth table0%0/2
A
A= $_[0]
Aresult
11
00
51  
52 32 our $DIE_MESSAGE = "LaTeXML died!\n"; # with cr
53 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 # Terminal setup
55  
56 # Color setup
57 # Possibly more dynamic?
58 32 $Term::ANSIColor::AUTORESET = 1;
59  
60 # Possibility of more terminal initialization & control?
61 sub UseSTDERR {
62 0 ▶ if (scalar(@_) && !$_[0]) { # Single false argument? Turn OFF
Subroutine UseSTDERR: not called CC=9 SCAR=42.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ and not $_[0]) { } 0 0 0
Condition0%0/3
scalar @_ and not $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @_ and not $_[0]
scalar @_ not $_[0]
Truth table0%0/3
A and not(B)
A= scalar @_B= not $_[0]
ABresult
0X0
100
111
63 0 ▶ _spinnerclear() if $USE_STDERR && $IS_TERMINAL;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::IS_TERMINAL
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::IS_TERMINAL
ABresult
0X0
100
111
64 0 $USE_STDERR = undef;
65 0 $IS_TERMINAL = undef; }
66 else {
67 0 $USE_STDERR = 1;
68 0 $IS_TERMINAL = -t STDERR;
69 0 binmode(STDERR, ":encoding(UTF-8)");
70 32 ▶ use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 0 *STDERR->autoflush();
72  
73 # Win32 console handling
74 0 ▶ if ($IS_TERMINAL && eval { require Win32::Console; }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::IS_TERMINAL and eval { do { require Win32::Console } }) 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::IS_TERMINAL and eval { do { require Win32::Console } }
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::IS_TERMINAL and eval { do { require Win32::Console } }
$LaTeXML::Common::Error::IS_TERMINAL eval { do { require Win32::Console } }
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::IS_TERMINALB= eval { do { require Win32::Console } }
ABresult
0X0
100
111
75 # set utf-8 codepage
76 # CP_UTF8 = 65001
77 0 Win32::Console::OutputCP(65001);
78  
79 # get standard error console
80 0 our $W32_STDERR = Win32::Console->new(&Win32::Console::STD_ERROR_HANDLE());
81  
82 # enable VT100 emulation or fall back to ANSI emulation if unsuccessful
83 # ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004 (not exported by Win32::Console)
84 0 my $mode = $W32_STDERR->Mode();
85 0 ▶ unless ($W32_STDERR->Mode($mode | 0x0004) && $W32_STDERR->Mode() & 0x0004) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($LaTeXML::Common::Error::W32_STDERR->Mode($mode | 4) and $LaTeXML::Common::Error::W32_STDERR->Mode & 4) 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::W32_STDERR->Mode($mode | 4) and $LaTeXML::Common::Error::W32_STDERR->Mode & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::W32_STDERR->Mode($mode | 4) and $LaTeXML::Common::Error::W32_STDERR->Mode & 4
$LaTeXML::Common::Error::W32_STDERR->Mode($mode | 4) $LaTeXML::Common::Error::W32_STDERR->Mode & 4
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::W32_STDERR->Mode($mode | 4)B= $LaTeXML::Common::Error::W32_STDERR->Mode & 4
ABresult
0X0
100
111
86 0 require Win32::Console::ANSI; } } }
87  
88 0 return; }
89  
90 32 our %color_scheme = (
91 details => 'bold',
92 success => 'green',
93 info => 'bright_blue', # bright only recently defined
94 warning => 'yellow',
95 error => 'bold red',
96 fatal => 'bold red underline',
97 );
98  
99 sub colorizeString {
100 0 ▶ my ($string, $alias) = @_;
Subroutine colorizeString: not called CC=3 SCAR=24.8
Pod undocumented
101 return ($IS_TERMINAL && $color_scheme{$alias}
102 0 ▶ ? colored($string, $color_scheme{$alias})
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Common::Error::IS_TERMINAL && $LaTeXML::Common::Error::color_scheme{$alias} ? : 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::color_scheme{$alias}
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::color_scheme{$alias}
$LaTeXML::Common::Error::IS_TERMINAL $LaTeXML::Common::Error::color_scheme{$alias}
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::IS_TERMINALB= $LaTeXML::Common::Error::color_scheme{$alias}
ABresult
0X0
100
111
103 : $string); }
104  
105 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 # Log file
107 32 our $LOG;
108 32 our $LOG_PATH;
109 # NOTE: since LaTeXML.pm (currently) repeatedly opens & closes the log,
110 # and doesn't (YET) know whether there's already a log open,
111 # this bit of hackery only keeps the outermost log open. FIX THIS!
112 32 our $log_count = 0;
113 # Where? Current directory? (probably) Source directory? (probably not)
114 # Option for appending?
115 # Note that the $path can be a reference to a string (which gets appended to)
116  
117 sub UseLog {
118 0 ▶ my ($path, $append) = @_;
Subroutine UseLog: not called CC=9 SCAR=45.0
Pod documented
119 0 ▶ if (!$path) { # Single false argument? Turn OFF and Close
Branch: 1 branch
BranchTrueFalseTotal
if (not $path) { } 0 0 0
120 0 $log_count--;
121 0 ▶ return if !$LOG || $log_count;
Branch: 1 branch
BranchTrueFalseTotal
if not $LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::log_count 0 0 0
Condition0%0/3
not $LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::log_count
l!l&&r!l&&!r
000
MC/DC0%0/2
not $LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::log_count
not $LaTeXML::Common::Error::LOG $LaTeXML::Common::Error::log_count
Truth table0%0/3
not(A) or B
A= not $LaTeXML::Common::Error::LOGB= $LaTeXML::Common::Error::log_count
ABresult
1X1
011
000
122 # ensure trailing newline when flushing, since we may have
123 # multiple re-opens during the same conversion run (preamble, main, post ...)
124 0 print $LOG _freshline($LOG);
125 0 ▶ close($LOG) or die "Cannot close log file: $!";
Branch: 1 branch
BranchTrueFalseTotal
close $LaTeXML::Common::Error::LOG or die "Cannot close log file: $!" 0 0 0
126 0 $LOG = undef; }
127 else {
128 0 $log_count++;
129 0 ▶ return if $LOG or not($path); # already opened?
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::LOG or not $path 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::LOG or not $path
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::Common::Error::LOG or not $path
$LaTeXML::Common::Error::LOG not $path
Truth table0%0/3
A or not(B)
A= $LaTeXML::Common::Error::LOGB= not $path
ABresult
1X1
011
000
130 0 pathname_mkdir(pathname_directory($path)); # and hopefully no errors! :>
131 0 ▶ open($LOG, ($append ? '>>' : '>'), $path) or die "Cannot open log file $path for writing: $!";
Branch: 2 branches
BranchTrueFalseTotal
open $LaTeXML::Common::Error::LOG, $append ? ">>" : ">", $path or die "Cannot open log file $path for writing: $!" 0 0 0
$append ? : 0 0 0
132 0 $LOG_PATH = $path;
133 0 binmode($LOG, ":encoding(UTF-8)"); }
134 0 return; }
135  
136 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 # Low-level I/O
138  
139 # print one (or more) lines to the Log, if opened
140 # Print first line to STDERR if enabled & verbosity >= 0
141 # Starts a fresh line by pushing any Spinner line ahead.
142 sub _printline {
143 0 ▶ my ($message) = @_;
Subroutine _printline: not called CC=14 SCAR=53.5
144 0 ▶ return if (!$LOG && !($USE_STDERR && ($VERBOSITY >= 0)));
Branch: 1 branch
BranchTrueFalseTotal
unless $LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
l!l&&r!l&&!r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::LOG $LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/4
A or B and C
A= $LaTeXML::Common::Error::LOGB= $LaTeXML::Common::Error::USE_STDERRC= $LaTeXML::Common::Error::VERBOSITY >= 0
ABCresult
1XX1
0111
00X0
0100
145 0 $message =~ s/^\n+//s; # Strip newlines off ends.
146 0 $message =~ s/\n+$//s;
147 0 ▶ if (my $clean_message = ($LOG || !$IS_TERMINAL ? strip_ansi($message) : $message)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $clean_message = $LaTeXML::Common::Error::LOG || !$LaTeXML::Common::Error::IS_TERMINAL ? strip_ansi($message) : $message) 0 0 0
$LaTeXML::Common::Error::LOG || !$LaTeXML::Common::Error::IS_TERMINAL ? : 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::LOG or not $LaTeXML::Common::Error::IS_TERMINAL
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::Common::Error::LOG or not $LaTeXML::Common::Error::IS_TERMINAL
$LaTeXML::Common::Error::LOG not $LaTeXML::Common::Error::IS_TERMINAL
Truth table0%0/3
A or not(B)
A= $LaTeXML::Common::Error::LOGB= not $LaTeXML::Common::Error::IS_TERMINAL
ABresult
1X1
011
000
148 0 ▶ $message = $clean_message unless $IS_TERMINAL;
Branch: 1 branch
BranchTrueFalseTotal
unless $LaTeXML::Common::Error::IS_TERMINAL 0 0 0
149 0 ▶ if ($LOG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::LOG) 0 0 0
150 0 print $LOG _freshline($LOG), $clean_message, "\n"; }
151 # Spinner logic only for terminal-enabled applications
152 0 ▶ if ($USE_STDERR && ($VERBOSITY >= 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0) 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::VERBOSITY >= 0
ABresult
0X0
100
111
153 0 _spinnerclear();
154 0 my $short = $message;
155 0 ▶ if ($short =~ /^([^\n]*)(:?\n\s*(at\s+[^\n]*))?/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($short =~ /^([^\n]*)(:?\n\s*(at\s+[^\n]*))?/s) 0 0 0
156 0 my ($first, $more, $at) = ($1, $2, $3);
157 0 ▶ $at =~ s/\s+-\s+.*$// if $at;
Branch: 1 branch
BranchTrueFalseTotal
if $at 0 0 0
158 0 $short = $first;
159 0 ▶ $short .= ' ' . $at if $at; }
Branch: 1 branch
BranchTrueFalseTotal
if $at 0 0 0
160 0 print STDERR _freshline(\*STDERR), $short, "\n"; ##}
161 0 _spinnerrestore(); } }
162 0 return; }
163  
164 # Similar, but print ALL lines to STDERR as well.
165 sub _printlines {
166 0 ▶ my ($message) = @_;
Subroutine _printlines: not called CC=11 SCAR=48.8
167 0 ▶ return if (!$LOG && !($USE_STDERR && ($VERBOSITY >= 0)));
Branch: 1 branch
BranchTrueFalseTotal
unless $LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
l!l&&r!l&&!r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::LOG $LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/4
A or B and C
A= $LaTeXML::Common::Error::LOGB= $LaTeXML::Common::Error::USE_STDERRC= $LaTeXML::Common::Error::VERBOSITY >= 0
ABCresult
1XX1
0111
00X0
0100
168 0 $message =~ s/^\n+//s; # Strip newlines off ends.
169 0 $message =~ s/\n+$//s;
170 0 ▶ if (my $clean_message = ($LOG || !$IS_TERMINAL ? strip_ansi($message) : $message)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $clean_message = $LaTeXML::Common::Error::LOG || !$LaTeXML::Common::Error::IS_TERMINAL ? strip_ansi($message) : $message) 0 0 0
$LaTeXML::Common::Error::LOG || !$LaTeXML::Common::Error::IS_TERMINAL ? : 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::LOG or not $LaTeXML::Common::Error::IS_TERMINAL
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::Common::Error::LOG or not $LaTeXML::Common::Error::IS_TERMINAL
$LaTeXML::Common::Error::LOG not $LaTeXML::Common::Error::IS_TERMINAL
Truth table0%0/3
A or not(B)
A= $LaTeXML::Common::Error::LOGB= not $LaTeXML::Common::Error::IS_TERMINAL
ABresult
1X1
011
000
171 0 ▶ $message = $clean_message unless $IS_TERMINAL;
Branch: 1 branch
BranchTrueFalseTotal
unless $LaTeXML::Common::Error::IS_TERMINAL 0 0 0
172 0 ▶ if ($LOG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::LOG) 0 0 0
173 0 print $LOG _freshline($LOG), $clean_message, "\n"; }
174 # Spinner logic only for terminal-enabled applications
175 0 ▶ if ($USE_STDERR && ($VERBOSITY >= 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0) 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::VERBOSITY >= 0
ABresult
0X0
100
111
176 0 _spinnerclear();
177 0 print STDERR _freshline(\*STDERR), $message, "\n"; ##}
178 0 _spinnerrestore(); } }
179 0 return; }
180  
181 32 our %NEEDSFRESHLINE = ();
182  
183 sub _freshline {
184 0 ▶ my ($stream) = @_;
Subroutine _freshline: not called CC=3 SCAR=24.8
185 0 ▶ if ($stream && $NEEDSFRESHLINE{$stream}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream and $LaTeXML::Common::Error::NEEDSFRESHLINE{$stream}) 0 0 0
Condition0%0/3
$stream and $LaTeXML::Common::Error::NEEDSFRESHLINE{$stream}
!ll&&!rl&&r
000
MC/DC0%0/2
$stream and $LaTeXML::Common::Error::NEEDSFRESHLINE{$stream}
$stream $LaTeXML::Common::Error::NEEDSFRESHLINE{$stream}
Truth table0%0/3
A and B
A= $streamB= $LaTeXML::Common::Error::NEEDSFRESHLINE{$stream}
ABresult
0X0
100
111
186 0 $NEEDSFRESHLINE{$stream} = 0;
187 0 return "\n"; }
188 0 return ''; }
189  
190 sub strip_ansi {
191 0 ▶ my ($string) = @_;
Subroutine strip_ansi: not called CC=1 SCAR=6.9
Pod undocumented
192 0 $string =~ s/\e\[[0-9;]*[a-zA-Z]//g;
193 0 return $string; }
194  
195 #======================================================================
196 sub StartTime {
197 0 ▶ return [Time::HiRes::gettimeofday]; }
Subroutine StartTime: not called CC=1 SCAR=6.9
Pod undocumented
198  
199 sub RunTime {
200 0 ▶ my ($starttime) = @_;
Subroutine RunTime: not called CC=3 SCAR=24.8
Pod undocumented
201 0 my $s = Time::HiRes::tv_interval($starttime, [Time::HiRes::gettimeofday]);
202 0 my ($h, $m);
203 0 $m = int($s / 60); $s -= 60 * $m;
204 0 $h = int($m / 60); $m -= 60 * $h;
205 0 ▶ return ($h ? $h . 'h ' : '') . ($m ? $m . 'm ' : '') . sprintf("%.2fs", $s); }
Branch: 2 branches
BranchTrueFalseTotal
$h ? : 0 0 0
$m ? : 0 0 0
206  
207 #======================================================================
208 # Spinner support
209 # Stack of [stage,count,count_message]
210 # Note: Would look prettier if we blank the cursor, but have to restore!
211 # Note: linewrap leaves terminal turds: the disable/enable codes are VT escape codes
212 32 our @spinnerstack = ();
213 32 our @spinnerchar = map { colored($_, "bold red"); } ('-', '\\', '|', '/');
214 32 our $spinnerpos = 0;
215 32 our $spinnerpre = "\x1b[1G\x1b[?7l"; # Cursor to col 1; turn off linewrap
216 32 our $spinnerpost = "\x1b[?7h";
217 # sub _spinnerreset {
218 # if($USE_STDERR && $IS_TERMINAL){
219 # print STDERR "\x1b[?7h"; } # Reset linewrap on
220 # return; }
221  
222 sub _spinnerclear { # Clear the spinner line (if any)
223 0 ▶ if ($USE_STDERR && $IS_TERMINAL && ($VERBOSITY >= 0) && @spinnerstack) {
Subroutine _spinnerclear: not called CC=5 SCAR=34.0
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack) 0 0 0
Condition0%0/9
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
MC/DC0%0/4
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::IS_TERMINAL $LaTeXML::Common::Error::VERBOSITY >= 0 @LaTeXML::Common::Error::spinnerstack
Truth table0%0/5
A and B and C and D
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::IS_TERMINALC= $LaTeXML::Common::Error::VERBOSITY >= 0D= @LaTeXML::Common::Error::spinnerstack
ABCDresult
0XXX0
10XX0
110X0
11100
11111
224 0 print STDERR "\x1b[1G\x1b[0K"; } # clear line
225 0 return; }
226  
227 sub _spinnerrestore { # Restore the spinner line (if any)
228 0 ▶ if ($USE_STDERR && $IS_TERMINAL && ($VERBOSITY >= 0) && @spinnerstack) {
Subroutine _spinnerrestore: not called CC=5 SCAR=34.0
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack) 0 0 0
Condition0%0/9
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
MC/DC0%0/4
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::IS_TERMINAL $LaTeXML::Common::Error::VERBOSITY >= 0 @LaTeXML::Common::Error::spinnerstack
Truth table0%0/5
A and B and C and D
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::IS_TERMINALC= $LaTeXML::Common::Error::VERBOSITY >= 0D= @LaTeXML::Common::Error::spinnerstack
ABCDresult
0XXX0
10XX0
110X0
11100
11111
229 0 my ($stage, $short, $start) = @{ $spinnerstack[-1] };
230 print STDERR join(' ', $spinnerpre, $spinnerchar[$spinnerpos],
231 0 (map { $$_[1]; } @spinnerstack[0 .. $#spinnerstack - 1]), $stage), $spinnerpost; }
232 0 return; }
233  
234 sub _spinnerstep { # Increment stepper
235 0 ▶ my ($note) = @_;
Subroutine _spinnerstep: not called CC=6 SCAR=37.4
236 0 ▶ if ($USE_STDERR && $IS_TERMINAL && ($VERBOSITY >= 0) && @spinnerstack) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack) 0 0 0
Condition0%0/9
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
MC/DC0%0/4
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0 and @LaTeXML::Common::Error::spinnerstack
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::IS_TERMINAL $LaTeXML::Common::Error::VERBOSITY >= 0 @LaTeXML::Common::Error::spinnerstack
Truth table0%0/5
A and B and C and D
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::IS_TERMINALC= $LaTeXML::Common::Error::VERBOSITY >= 0D= @LaTeXML::Common::Error::spinnerstack
ABCDresult
0XXX0
10XX0
110X0
11100
11111
237 0 my ($stage, $short, $start) = @{ $spinnerstack[-1] };
238 0 $spinnerpos = ($spinnerpos + 1) % 4;
239 0 ▶ if ($note) { # If note, redraw whole line.
Branch: 1 branch
BranchTrueFalseTotal
if ($note) { } 0 0 0
240 print STDERR join(' ', $spinnerpre, $spinnerchar[$spinnerpos],
241 0 (map { $$_[1]; } @spinnerstack), $note, "\x1b[0K"), $spinnerpost; }
242 else { # overwrite previous spinner
243 0 print STDERR $spinnerpre . ' ', $spinnerchar[$spinnerpos], $spinnerpost; } }
244 0 return; }
245  
246 sub _spinnerpush { # New spinner level
247 0 ▶ my ($stage) = @_;
Subroutine _spinnerpush: not called CC=3 SCAR=24.8
248 0 ▶ my $short = ($stage =~ /^(\w+)\s+(.*)$/ && $2 ? "$1 >" : $stage);
Branch: 1 branch
BranchTrueFalseTotal
$stage =~ /^(\w+)\s+(.*)$/ && $2 ? : 0 0 0
Condition0%0/3
$stage =~ /^(\w+)\s+(.*)$/ and $2
!ll&&!rl&&r
000
MC/DC0%0/2
$stage =~ /^(\w+)\s+(.*)$/ and $2
$stage =~ /^(\w+)\s+(.*)$/ $2
Truth table0%0/3
A and B
A= $stage =~ /^(\w+)\s+(.*)$/B= $2
ABresult
0X0
100
111
249 0 push(@spinnerstack, [$stage, $short, [Time::HiRes::gettimeofday]]);
250 0 return; }
251  
252 sub _spinnerpop { # Finished with spinner level
253 0 ▶ my ($stage) = @_;
Subroutine _spinnerpop: not called CC=7 SCAR=40.3
254 0 ▶ if (@spinnerstack && ($stage eq $spinnerstack[-1][0])) {
Branch: 2 branches
BranchTrueFalseTotal
if (@LaTeXML::Common::Error::spinnerstack and $stage eq $LaTeXML::Common::Error::spinnerstack[-1][0]) { } 0 0 0
elsif ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0) { } 0 0 0
Condition0%0/3
@LaTeXML::Common::Error::spinnerstack and $stage eq $LaTeXML::Common::Error::spinnerstack[-1][0]
!ll&&!rl&&r
000
MC/DC0%0/2
@LaTeXML::Common::Error::spinnerstack and $stage eq $LaTeXML::Common::Error::spinnerstack[-1][0]
@LaTeXML::Common::Error::spinnerstack $stage eq $LaTeXML::Common::Error::spinnerstack[-1][0]
Truth table0%0/3
A and B
A= @LaTeXML::Common::Error::spinnerstackB= $stage eq $LaTeXML::Common::Error::spinnerstack[-1][0]
ABresult
0X0
100
111
255 0 my ($xstage, $short, $start) = @{ pop(@spinnerstack) };
256 0 return Time::HiRes::tv_interval($start, [Time::HiRes::gettimeofday]); }
257 ▶ elsif ($USE_STDERR && ($VERBOSITY >= 0)) { # What else to do about mis-matched begin/end ??
Condition0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::VERBOSITY >= 0
ABresult
0X0
100
111
258 0 ▶ print STDERR "SPINNER is " . ((@spinnerstack && $spinnerstack[-1][0]) || 'undef') . " not $stage\n"; }
Condition0%0/5
@LaTeXML::Common::Error::spinnerstack && $LaTeXML::Common::Error::spinnerstack[-1][0] || 'undef'
l!l
00
@LaTeXML::Common::Error::spinnerstack and $LaTeXML::Common::Error::spinnerstack[-1][0]
!ll&&!rl&&r
000
MC/DC0%0/2
@LaTeXML::Common::Error::spinnerstack && $LaTeXML::Common::Error::spinnerstack[-1][0] || 'undef'
@LaTeXML::Common::Error::spinnerstack $LaTeXML::Common::Error::spinnerstack[-1][0]
Truth table0%0/3
A and B
A= @LaTeXML::Common::Error::spinnerstackB= $LaTeXML::Common::Error::spinnerstack[-1][0]
ABresult
111
0X0
100
259 0 return; }
260  
261 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262 # Error reporting
263 # Public API
264  
265 sub Fatal {
266 0 ▶ my ($category, $object, $where, $message, @details) = @_;
Subroutine Fatal: not called CC=16 SCAR=56.1
Pod documented
267  
268 # Check if this is a known unsafe fatal and flag it if so (so that we reinitialize in daemon contexts)
269 0 ▶ if ((($category eq 'internal') && ($object eq '<recursion>')) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($category eq "internal" and $object eq "<recursion>" or $category eq "too_many_errors" or $object eq "deep_recursion" or $object eq "die") 0 0 0
Condition0%0/12
$category eq "internal" and $object eq "<recursion>" or $category eq "too_many_errors" or $object eq "deep_recursion" or $object eq "die"
l!l&&r!l&&!r
000
$category eq "internal" and $object eq "<recursion>" or $category eq "too_many_errors" or $object eq "deep_recursion"
l!l&&r!l&&!r
000
$category eq "internal" and $object eq "<recursion>" or $category eq "too_many_errors"
l!l&&r!l&&!r
000
$category eq "internal" and $object eq "<recursion>"
!ll&&!rl&&r
000
MC/DC0%0/5
$category eq "internal" and $object eq "<recursion>" or $category eq "too_many_errors" or $object eq "deep_recursion" or $object eq "die"
$category eq "internal" $object eq "<recursion>" $category eq "too_many_errors" $object eq "deep_recursion" $object eq "die"
Truth table0%0/9
A and B or C or D or E
A= $category eq "internal"B= $object eq "<recursion>"C= $category eq "too_many_errors"D= $object eq "deep_recursion"E= $object eq "die"
ABCDEresult
11XXX1
0X1XX1
101XX1
0X01X1
1001X1
0X0011
100011
0X0000
100000
270 ($category eq 'too_many_errors') ||
271 ($object eq 'deep_recursion') || ($object eq 'die')) {
272 0 $LaTeXML::UNSAFE_FATAL = 1; }
273  
274 # We'll assume that if the DIE handler is bound (presumably to this function)
275 # we're in the outermost call to Fatal; we'll clear the handler so that we don't nest calls.
276 die $DIE_MESSAGE if $LaTeXML::IGNORE_ERRORS # Short circuit, w/no formatting, if in probing eval
277 0 ▶ || (($SIG{__DIE__} eq 'DEFAULT') && $^S); # Also missing class when parsing bindings(?!?!)
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::IGNORE_ERRORS or $SIG{"__DIE__"} eq "DEFAULT" and $^S 0 0 0
Condition0%0/6
$LaTeXML::IGNORE_ERRORS or $SIG{"__DIE__"} eq "DEFAULT" and $^S
l!l&&r!l&&!r
000
$SIG{"__DIE__"} eq "DEFAULT" and $^S
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::IGNORE_ERRORS or $SIG{"__DIE__"} eq "DEFAULT" and $^S
$LaTeXML::IGNORE_ERRORS $SIG{"__DIE__"} eq "DEFAULT" $^S
Truth table0%0/4
A or B and C
A= $LaTeXML::IGNORE_ERRORSB= $SIG{"__DIE__"} eq "DEFAULT"C= $^S
ABCresult
1XX1
0111
00X0
0100
278  
279 0 my $inhandler = !$SIG{__DIE__};
280 0 my $ineval = 0; # whether we're in an eval should no longer matter!
281  
282 # This seemingly should be "local", but that doesn't seem to help with timeout/alarm/term?
283 # It should be safe so long as the caller has bound it and rebinds it if necessary.
284 0 local $SIG{__DIE__} = 'DEFAULT'; # Avoid recursion while preparing the message.
285 0 my $state = $STATE;
286  
287 0 ▶ if (!$inhandler) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $inhandler) { } 0 0 0
288 0 local $LaTeXML::BAILOUT = $LaTeXML::BAILOUT;
289 0 ▶ if (checkRecursiveError()) {
Branch: 1 branch
BranchTrueFalseTotal
if (checkRecursiveError()) 0 0 0
290 0 $LaTeXML::BAILOUT = 1;
291 0 push(@details, "Recursive Error!"); }
292 0 ▶ $state->noteStatus('fatal') if $state && !$ineval;
Branch: 1 branch
BranchTrueFalseTotal
if $state and not $ineval 0 0 0
Condition0%0/3
$state and not $ineval
!ll&&!rl&&r
000
MC/DC0%0/2
$state and not $ineval
$state not $ineval
Truth table0%0/3
A and not(B)
A= $stateB= not $ineval
ABresult
0X0
100
111
293 0 ▶ my $detail_level = (($VERBOSITY <= 1) && ($category =~ /^(?:timeout|too_many_errors)$/)) ? 0 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Common::Error::VERBOSITY <= 1 && $category =~ /^(?:timeout|too_many_errors)$/ ? : 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::VERBOSITY <= 1 and $category =~ /^(?:timeout|too_many_errors)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::VERBOSITY <= 1 and $category =~ /^(?:timeout|too_many_errors)$/
$LaTeXML::Common::Error::VERBOSITY <= 1 $category =~ /^(?:timeout|too_many_errors)$/
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::VERBOSITY <= 1B= $category =~ /^(?:timeout|too_many_errors)$/
ABresult
0X0
100
111
294 0 $message
295 = generateMessage(colorizeString("Fatal:" . $category . ":" . ToString($object), 'fatal'),
296 $where, $message, $detail_level, @details);
297 # If we're about to (really) DIE, we'll bypass the usual status message, so add it here.
298 # This really should be handled by the top-level program,
299 # after doing all processing within an eval
300 # BIZARRE: Note that die adds the "at <file> <line>" stuff IFF the message doesn't end w/ CR!
301 #### $message .= $state->getStatusMessage . "\n" if $state && !$ineval;
302 }
303 else { # If we ARE in a recursive call, the actual message is $details[0]
304 0 ▶ $message = $details[0] if $details[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if $details[0] 0 0 0
305 # inhibit message to STDERR, since die will handle that
306 0 _printlines($message);
307 0 hardYankProcessing();
308 # Now that we have yanked the processing state, ignore any following errors
309 0 $LaTeXML::IGNORE_ERRORS = 1;
310  
311 # If inside an eval, this won't actually die, but WILL set $@ for caller's use.
312 0 die $DIE_MESSAGE; }
313  
314 sub hardYankProcessing {
315 0 ▶ my $state = $STATE;
Subroutine hardYankProcessing: not called CC=6 SCAR=37.4
Pod undocumented
316 # Nothing we can do if we are called without a global $STATE bound
317 0 ▶ return unless $state;
Branch: 1 branch
BranchTrueFalseTotal
unless $state 0 0 0
318 # Ensure we have nothing else to do in the main processing.
319 # NOTE: this recovery procedure must always be run after all logging messages are generated,
320 # as resetting the various stacks loses information (e.g. location is lost).
321 0 my $stomach = $$state{stomach};
322 0 my $gullet = $$stomach{gullet};
323 0 $$stomach{token_stack} = [];
324 # If we were in an infinite loop, disable any potential busy token.
325 0 my $relax_def = $$state{meaning}{"\\relax"}[0];
326 0 ▶ $state->assignMeaning($LaTeXML::CURRENT_TOKEN, $relax_def, 'global') if $LaTeXML::CURRENT_TOKEN;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::CURRENT_TOKEN 0 0 0
327 0 for my $token (@{ $$gullet{pushback} }) {
328 0 $state->assignMeaning($token, $relax_def, 'global'); }
329 # Rescue data structures that may be serializable/resumable
330 0 ▶ if (@LaTeXML::LIST) {
Branch: 1 branch
BranchTrueFalseTotal
if (@LaTeXML::LIST) 0 0 0
331 0 $$stomach{rescued_boxes} = [@LaTeXML::LIST];
332 0 @LaTeXML::LIST = ();
333 }
334 0 ▶ if ($LaTeXML::DOCUMENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::DOCUMENT) 0 0 0
335 0 $$state{rescued_document} = $LaTeXML::DOCUMENT; }
336 # avoid looping at \end{document}, Fatal brings us back to the doc level
337 0 $state->assignValue('current_environment', undef, 'global');
338 # then reset the gullet
339 0 $$gullet{pushback} = [];
340 0 $$gullet{mouthstack} = [];
341 0 $$gullet{pending_comments} = [];
342 0 $$gullet{mouth} = LaTeXML::Core::Mouth->new();
343 0 return; }
344  
345 sub checkRecursiveError {
346 0 ▶ my @caller;
Subroutine checkRecursiveError: not called CC=3 SCAR=24.8
Pod undocumented
347 0 ▶ for (my $frame = 2 ; @caller = caller($frame) ; $frame++) {
Branch: 1 branch
BranchTrueFalseTotal
if (@caller = caller $frame) 0 0 0
348 0 ▶ if ($caller[3] =~ /^LaTeXML::(Global::ToString|Global::Stringify)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller[3] =~ /^LaTeXML::(Global::ToString|Global::Stringify)$/) 0 0 0
349 # print STDERR "RECURSED ON $caller[3]\n";
350 0 return 1; } }
351 0 return; }
352  
353 # Should be fatal if strict is set, else warn.
354 sub Error {
355 0 ▶ my ($category, $object, $where, $message, @details) = @_;
Subroutine Error: not called CC=10 SCAR=47.0
Pod documented
356 0 ▶ return if $LaTeXML::IGNORE_ERRORS;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::IGNORE_ERRORS 0 0 0
357 0 my $state = $STATE;
358 0 ▶ $state && $state->noteStatus('error');
Branch: 1 branch
BranchTrueFalseTotal
$state and $state->noteStatus("error") 0 0 0
359 0 ▶ if ($state && $state->lookupValue('STRICT')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state and $state->lookupValue('STRICT')) { } 0 0 0
Condition0%0/3
$state and $state->lookupValue("STRICT")
!ll&&!rl&&r
000
MC/DC0%0/2
$state and $state->lookupValue("STRICT")
$state $state->lookupValue("STRICT")
Truth table0%0/3
A and B
A= $stateB= $state->lookupValue("STRICT")
ABresult
0X0
100
111
360 0 Fatal($category, $object, $where, $message, @details); }
361 else {
362 0 my $formatted = generateMessage("Error:" . $category . ":" . ToString($object),
363 $where, $message, 1, @details);
364 0 _printline($formatted); }
365 # Note that "100" is hardwired into TeX, The Program!!!
366 0 ▶ my $maxerrors = ($state ? $state->lookupValue('MAX_ERRORS') : 100);
Branch: 1 branch
BranchTrueFalseTotal
$state ? : 0 0 0
367 0 ▶ if ($state && (defined $maxerrors) && (($state->getStatus('error') || 0) > $maxerrors)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state and defined $maxerrors and ($state->getStatus("error") || 0) > $maxerrors) 0 0 0
Condition0%0/8
$state and defined $maxerrors and ($state->getStatus("error") || 0) > $maxerrors
!ll&&!rl&&r
000
$state and defined $maxerrors
!ll&&!rl&&r
000
$state->getStatus('error') || 0
l!l
00
MC/DC0%0/3
$state and defined $maxerrors and ($state->getStatus("error") || 0) > $maxerrors
$state defined $maxerrors $state->getStatus('error')
Truth table0%0/4
A and B and C
A= $stateB= defined $maxerrorsC= $state->getStatus('error')
ABCresult
0XX0
10X0
1100
1111
368 0 Fatal('too_many_errors', $maxerrors, $where, "Too many errors (> $maxerrors)!"); }
369 0 return; }
370  
371 # Warning message; results may be OK, but somewhat unlikely
372 sub Warn {
373 0 ▶ my ($category, $object, $where, $message, @details) = @_;
Subroutine Warn: not called CC=3 SCAR=24.8
Pod documented
374 0 ▶ return if $LaTeXML::IGNORE_ERRORS;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::IGNORE_ERRORS 0 0 0
375 0 my $state = $STATE;
376 0 ▶ $state && $state->noteStatus('warning');
Branch: 1 branch
BranchTrueFalseTotal
$state and $state->noteStatus("warning") 0 0 0
377 0 my $formatted = generateMessage("Warning:" . $category . ":" . ToString($object),
378 $where, $message, 0, @details);
379 0 _printline($formatted);
380 0 return; }
381  
382 # Informational message; results likely unaffected
383 # but the message may give clues about subsequent warnings or errors
384 sub Info {
385 0 ▶ my ($category, $object, $where, $message, @details) = @_;
Subroutine Info: not called CC=3 SCAR=24.8
Pod documented
386 0 ▶ return if $LaTeXML::IGNORE_ERRORS;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::IGNORE_ERRORS 0 0 0
387 0 my $state = $STATE;
388 0 ▶ $state && $state->noteStatus('info');
Branch: 1 branch
BranchTrueFalseTotal
$state and $state->noteStatus("info") 0 0 0
389 0 my $formatted = generateMessage("Info:" . $category . ":" . ToString($object),
390 $where, $message, -1, @details);
391 0 _printline($formatted);
392 0 return; }
393  
394 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395 # Progress Reporting
396 #**********************************************************************
397  
398 sub Note {
399 0 ▶ my ($message) = @_;
Subroutine Note: not called CC=1 SCAR=6.9
Pod documented
400 0 _printline($message);
401 0 return; }
402  
403 sub NoteSTDERR {
404 0 ▶ my ($message) = @_;
Subroutine NoteSTDERR: not called CC=3 SCAR=24.8
Pod documented
405 0 ▶ if ($USE_STDERR && ($VERBOSITY >= 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0) 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::VERBOSITY >= 0
ABresult
0X0
100
111
406 0 _spinnerclear();
407 0 print STDERR _freshline(\*STDERR), $message, "\n";
408 0 _spinnerrestore(); }
409 0 return; }
410  
411 sub NoteLog {
412 0 ▶ my ($message) = @_;
Subroutine NoteLog: not called CC=2 SCAR=17.9
Pod documented
413 0 ▶ print $LOG _freshline($LOG), strip_ansi($message), "\n" if $LOG;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::LOG 0 0 0
414 0 return; }
415  
416 # Progress reporting.
417 # Needs LOG/STDERR sorted out. Maybe some Term magic on STDERR? (rotating "-"?)
418 # Possibly wants more explicit levels?
419 # or at least a report-always level?
420 sub ProgressStep {
421 0 ▶ my ($note) = @_;
Subroutine ProgressStep: not called CC=1 SCAR=6.9
Pod documented
422 0 _spinnerstep($note);
423 0 return; }
424  
425 sub ProgressSpinup {
426 0 ▶ my ($stage) = @_;
Subroutine ProgressSpinup: not called CC=9 SCAR=45.0
Pod documented
427 0 ▶ if ($LOG || ($USE_STDERR && ($VERBOSITY >= 0))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0) 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
l!l&&r!l&&!r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::LOG $LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/4
A or B and C
A= $LaTeXML::Common::Error::LOGB= $LaTeXML::Common::Error::USE_STDERRC= $LaTeXML::Common::Error::VERBOSITY >= 0
ABCresult
1XX1
0111
00X0
0100
428 0 my $message = "($stage...";
429 0 _spinnerclear();
430 0 _spinnerpush($stage);
431 0 _spinnerrestore();
432 0 ▶ if ($LOG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::LOG) 0 0 0
433 0 print $LOG _freshline($LOG), $message;
434 0 ▶ $NEEDSFRESHLINE{$LOG} = 1 if $LOG; }
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::LOG 0 0 0
435 0 ▶ if ($USE_STDERR && ($VERBOSITY >= 0) && !$IS_TERMINAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 and not $LaTeXML::Common::Error::IS_TERMINAL) 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 and not $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 and not $LaTeXML::Common::Error::IS_TERMINAL
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0 not $LaTeXML::Common::Error::IS_TERMINAL
Truth table0%0/4
A and B and not(C)
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::VERBOSITY >= 0C= not $LaTeXML::Common::Error::IS_TERMINAL
ABCresult
0XX0
10X0
1100
1111
436 0 print STDERR _freshline(\*STDERR), $message;
437 0 $NEEDSFRESHLINE{ \*STDERR } = 1; } }
438 0 return; }
439  
440 sub ProgressSpindown {
441 0 ▶ my ($stage) = @_;
Subroutine ProgressSpindown: not called CC=10 SCAR=47.0
Pod undocumented
442 0 ▶ if ($LOG || ($USE_STDERR && ($VERBOSITY >= 0))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0) 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
l!l&&r!l&&!r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::LOG or $LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::LOG $LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/4
A or B and C
A= $LaTeXML::Common::Error::LOGB= $LaTeXML::Common::Error::USE_STDERRC= $LaTeXML::Common::Error::VERBOSITY >= 0
ABCresult
1XX1
0111
00X0
0100
443 0 _spinnerclear();
444 0 my $elapsed = _spinnerpop($stage);
445 0 _spinnerrestore();
446 0 ▶ my $message = ($elapsed ? sprintf(" %.2f sec)", $elapsed) : '?');
Branch: 1 branch
BranchTrueFalseTotal
$elapsed ? : 0 0 0
447 0 ▶ print $LOG $message if $LOG;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::LOG 0 0 0
448 0 ▶ $NEEDSFRESHLINE{$LOG} = 1 if $LOG;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::LOG 0 0 0
449 0 ▶ if ($USE_STDERR && ($VERBOSITY >= 0) && !$IS_TERMINAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 and not $LaTeXML::Common::Error::IS_TERMINAL) 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 and not $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::VERBOSITY >= 0 and not $LaTeXML::Common::Error::IS_TERMINAL
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::VERBOSITY >= 0 not $LaTeXML::Common::Error::IS_TERMINAL
Truth table0%0/4
A and B and not(C)
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::VERBOSITY >= 0C= not $LaTeXML::Common::Error::IS_TERMINAL
ABCresult
0XX0
10X0
1100
1111
450 0 print STDERR $message;
451 0 $NEEDSFRESHLINE{ \*STDERR } = 1; } }
452 0 return; }
453  
454 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
455 # Debugging support.
456 # Short of real macros, here's a flexible, low-cost debug technique:
457 # Debug(message...) if $LaTeXML::DEBUG{feature};
458 32 our %Debugbable = ();
459 # %LaTeXML::DEBUG = {};
460  
461 sub DebuggableFeature {
462 10 ▶ my ($feature, $description) = @_;
Subroutine DebuggableFeature: called CC=1 SCAR=0.0
Pod documented
463 10 $LaTeXML::Debuggable{$feature} = $description;
464 10 return; }
465  
466 sub Debug {
467 0 ▶ my ($message) = @_;
Subroutine Debug: not called CC=1 SCAR=6.9
Pod documented
468 # Note: Could append source code location of the caller?
469 0 _printlines($message);
470 0 return; }
471  
472 # This only makes sense at end of run, after all needed modules have been loaded!
473 sub CheckDebuggable {
474 0 ▶ my %unknown = ();
Subroutine CheckDebuggable: not called CC=4 SCAR=30.0
Pod documented
475 0 foreach my $feature (keys %LaTeXML::DEBUG) {
476 0 ▶ $unknown{$feature} = 1 unless $LaTeXML::Debuggable{$feature}; }
Branch: 1 branch
BranchTrueFalseTotal
unless $LaTeXML::Debuggable{$feature} 0 0 0
477 # Now report unknown; suggest similar spellings ?
478 0 ▶ if (keys %unknown) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %unknown) 0 0 0
479 0 print STDERR _freshline(\*STDERR), "The debugging feature(s) " . join(', ', sort keys %unknown) . " were never declared\n";
480 0 print STDERR _freshline(\*STDERR), "Known debugging features: " . join(', ', sort keys %LaTeXML::Debuggable) . "\n"; }
481 0 return; }
482  
483 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484 # Handlers for perl's die & warn
485 # We'll try to decode some common errors to make them more usable
486 # for build systems.
487  
488 32 my $quoted_re = qr/\"([^\"]*)\"/; # [CONSTANT]
489 32 my $cantcall_re = qr/Can't call method/; # [CONSTANT]
490 32 my $cantlocate_re = qr/Can't locate object method/; # [CONSTANT]
491 32 my $undef_re = qr/Undefined subroutine/; # [CONSTANT]
492 32 my $noself_re = qr/on an undefined value|without a package or object reference/; # [CONSTANT]
493 32 my $via_re = qr/via package/; # [CONSTANT]
494 32 my $at_re = qr/(at .*)/; # [CONSTANT]
495  
496 sub perl_die_handler {
497 0 ▶ my (@line) = @_;
Subroutine perl_die_handler: not called CC=9 SCAR=45.0
Pod undocumented
498 0 ▶ if ($LaTeXML::IGNORE_ERRORS # Just get out now, if we're ignoring errors within an eval.
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::IGNORE_ERRORS or colorstrip($line[0]) =~ /^\s*Fatal:/) 0 0 0
Condition0%0/3
$LaTeXML::IGNORE_ERRORS or colorstrip($line[0]) =~ /^\s*Fatal:/
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::IGNORE_ERRORS or colorstrip($line[0]) =~ /^\s*Fatal:/
$LaTeXML::IGNORE_ERRORS colorstrip($line[0]) =~ /^\s*Fatal:/
Truth table0%0/3
A or B
A= $LaTeXML::IGNORE_ERRORSB= colorstrip($line[0]) =~ /^\s*Fatal:/
ABresult
1X1
011
000
499 || (colorstrip($line[0]) =~ /^\s*Fatal:/)) { # Or, we've already been through here.
500 0 local $SIG{__DIE__} = undef;
501 0 die @line; }
502 # We try to find a meaningful name for where the error occurred;
503 # That's the thing that is "misdefined", after all.
504 # Not completely sure we're looking in the right place up the stack, though.
505 0 ▶ if ($line[0] =~ /^$cantcall_re\s+$quoted_re\s+($noself_re)\s+$at_re$/) {
Branch: 6 branches
BranchTrueFalseTotal
if ($line[0] =~ /^$cantcall_re\s+$quoted_re\s+($noself_re)\s+$at_re$/) { } 0 0 0
elsif ($line[0] =~ /^$undef_re\s+(\S+)\s+called $at_re$/) { } 0 0 0
elsif ($line[0] =~ /^$cantlocate_re\s+$quoted_re\s+$via_re\s+$quoted_re\s+\(.*\)\s+$at_re/) { } 0 0 0
elsif ($line[0] =~ /^Can't locate \S* in \@INC \(you may need to install the (\S*) module\) \(\@INC contains: ([^\)]*)\) $at_re$/) { } 0 0 0
elsif ($line[0] =~ /^Can't use\s+(\w*)\s+\([^\)]*\) as (.*?) ref(?:\s+while "strict refs" in use)? at (.*)$/) { } 0 0 0
elsif ($line[0] =~ /^File (.*?) had an error:/) { } 0 0 0
506 0 my ($method, $kind, $where) = ($1, $2, $3);
507 0 Fatal('misdefined', callerName(1), $where,
508 "Can't call method '$method' $kind", @line[1 .. $#line]); }
509 elsif ($line[0] =~ /^$undef_re\s+(\S+)\s+called $at_re$/) {
510 0 my ($function, $where) = ($1, $2);
511 0 Fatal('misdefined', callerName(1), $where,
512 "Undefined subroutine '$function' called", @line[1 .. $#line]); }
513 elsif ($line[0] =~ /^$cantlocate_re\s+$quoted_re\s+$via_re\s+$quoted_re\s+\(.*\)\s+$at_re/) {
514 0 my ($method, $class, $where) = ($1, $2, $3);
515 0 Fatal('misdefined', callerName(1), $where,
516 "Can't locate method '$method' via '$class'", @line[1 .. $#line]); }
517 elsif ($line[0] =~ /^Can't locate \S* in \@INC \(you may need to install the (\S*) module\) \(\@INC contains: ([^\)]*)\) $at_re$/) {
518 0 my ($class, $inc, $where) = ($1, $2);
519 0 Fatal('misdefined', callerName(1), $where,
520 "Can't locate class '$class' (not installed or misspelled?)", @line[1 .. $#line]); }
521 elsif ($line[0] =~ /^Can't use\s+(\w*)\s+\([^\)]*\) as (.*?) ref(?:\s+while "strict refs" in use)? at (.*)$/) {
522 0 my ($gottype, $wanttype, $where) = ($1, $2, $3);
523 0 Fatal('misdefined', callerName(1), $where,
524 "Can't use $gottype as $wanttype reference", @line[1 .. $#line]); }
525 elsif ($line[0] =~ /^File (.*?) had an error:/) {
526 0 my ($file) = ($1);
527 0 Fatal('misdefined', $file, undef, @line); }
528 else {
529 0 Fatal('perl', 'die', undef, "Perl died", @line); }
530 0 return; }
531  
532 sub perl_warn_handler {
533 0 ▶ my (@line) = @_;
Subroutine perl_warn_handler: not called CC=6 SCAR=37.4
Pod undocumented
534 0 ▶ return if $LaTeXML::IGNORE_ERRORS;
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::IGNORE_ERRORS 0 0 0
535 0 ▶ if ($line[0] =~ /^Use of uninitialized value (.*?)(\s?+in .*?)\s+(at\s+.*?\s+line\s+\d+)\.$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line[0] =~ /^Use of uninitialized value (.*?)(\s?+in .*?)\s+(at\s+.*?\s+line\s+\d+)\.$/) { } 0 0 0
elsif ($line[0] =~ /^Deep recursion on/) { } 0 0 0
elsif ($line[0] =~ /^(.*?)\s+(at\s+.*?\s+line\s+\d+)\.$/) { } 0 0 0
536 0 ▶ my ($what, $how, $where) = ($1 || 'value', $2, $3);
Condition0%0/2
$1 || 'value'
l!l
00
MC/DC0%0/1
$1 || 'value'
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
537 0 Warn('uninitialized', $what, $where, "Use of uninitialized value $what $how", @line[1 .. $#line]); }
538 elsif ($line[0] =~ /^Deep recursion on/) {
539 0 Fatal('perl', 'deep_recursion', undef, $line[0]); }
540 elsif ($line[0] =~ /^(.*?)\s+(at\s+.*?\s+line\s+\d+)\.$/) {
541 0 my ($warning, $where) = ($1, $2);
542 0 Warn('perl', 'warn', undef, $warning, $where, @line[1 .. $#line]); }
543 else {
544 0 Warn('perl', 'warn', undef, @line); }
545 0 return; }
546  
547 # The following handlers SHOULD report the problem,
548 # even when within a "safe" eval that's ignoring errors.
549 # Moreover, we'd really like to be able to throw all the way to
550 # the top-level containing eval. How to do that?
551 sub perl_interrupt_handler {
552 0 ▶ my (@line) = @_;
Subroutine perl_interrupt_handler: not called CC=1 SCAR=6.9
Pod undocumented
553 0 $LaTeXML::IGNORE_ERRORS = 0; # NOT ignored
554 0 $LaTeXML::UNSAFE_FATAL = 1;
555 0 Fatal('interrupt', 'interrupted', undef, "LaTeXML was interrupted", @line);
556 0 return; }
557  
558 sub perl_timeout_handler {
559 0 ▶ my (@line) = @_;
Subroutine perl_timeout_handler: not called CC=1 SCAR=6.9
Pod undocumented
560 0 $LaTeXML::IGNORE_ERRORS = 0; # NOT ignored
561 0 $LaTeXML::UNSAFE_FATAL = 1;
562 0 Fatal('timeout', 'timedout', undef, "Conversion timed out", @line);
563 0 return; }
564  
565 sub perl_terminate_handler {
566 0 ▶ my (@line) = @_;
Subroutine perl_terminate_handler: not called CC=1 SCAR=6.9
Pod undocumented
567 0 $LaTeXML::IGNORE_ERRORS = 0; # NOT ignored
568 0 $LaTeXML::UNSAFE_FATAL = 1;
569 0 Fatal('terminate', 'terminated', undef, "Conversion was terminated", @line);
570 0 return; }
571  
572 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 # Internals
574 # Synthesize an error message describing what happened, and where.
575 # $detail specifies the level of detail
576 # $detail == -1 : no context or stack
577 # $detail == 0 : context, no stack
578 # $detail == +1 : context & stack
579 # including a level requesting full stack trace?
580  
581 sub generateMessage {
582 0 ▶ my ($errorcode, $where, $message, $detail, @extra) = @_;
Subroutine generateMessage: not called CC=30 SCAR=68.4
Pod documented
583 # Colorize errorcode if appropriate
584 0 ▶ if ($USE_STDERR && $IS_TERMINAL && ($VERBOSITY >= 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0) 0 0 0
Condition0%0/6
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0
!ll&&!rl&&r
000
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL
!ll&&!rl&&r
000
MC/DC0%0/3
$LaTeXML::Common::Error::USE_STDERR and $LaTeXML::Common::Error::IS_TERMINAL and $LaTeXML::Common::Error::VERBOSITY >= 0
$LaTeXML::Common::Error::USE_STDERR $LaTeXML::Common::Error::IS_TERMINAL $LaTeXML::Common::Error::VERBOSITY >= 0
Truth table0%0/4
A and B and C
A= $LaTeXML::Common::Error::USE_STDERRB= $LaTeXML::Common::Error::IS_TERMINALC= $LaTeXML::Common::Error::VERBOSITY >= 0
ABCresult
0XX0
10X0
1100
1111
585 0 $errorcode =~ /^(\w+)\:/;
586 0 ▶ my $errorkind = $1 && lc($1);
Condition0%0/3
$1 && lc $1
!ll&&!rl&&r
000
MC/DC0%0/2
$1 && lc $1
$1 lc $1
Truth table0%0/3
A && B
A= $1B= lc $1
ABresult
0X0
100
111
587 0 ▶ $errorcode = colorizeString($errorcode, $errorkind) if $errorkind; }
Branch: 1 branch
BranchTrueFalseTotal
if $errorkind 0 0 0
588  
589 #----------------------------------------
590 # Generate location information; basic and for stack trace.
591 # If we've been given an object $where, where the error occurred, use it.
592 0 my $docloc = getLocation($where);
593 0 ▶ $docloc = defined $docloc ? ToString($docloc) : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $docloc ? : 0 0 0
594  
595 # $message and each of @extra should be single lines
596 0 @extra = grep { $_ ne '' } map { split("\n", $_) } grep { defined $_ } $message, @extra;
597 # make 1st line be 1st line of message
598 0 $message = shift(@extra);
599 # $message =~ s/\n.*//g;
600 # The initial portion of the message will consist of:
601 0 ▶ $message = '' unless defined $message;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 0 0
602 0 ▶ my @lines = (
Branch: 1 branch
BranchTrueFalseTotal
$docloc ? : 0 0 0
603 # Start with the error code & primary error message
604 $errorcode . ' ' . $message,
605 # Followed by single line location of where the message occurred (if we know)
606 ($docloc ? ('at ' . $docloc) : ()),
607 # and then any additional message lines supplied
608 @extra);
609  
610 #----------------------------------------
611 # Now add some additional context
612 # NOTE: Should skip this for INFO
613 # NOTE: Need to pass more of this onto the objects themselves....
614 # What should it be called?
615 # showErrorContext() ?????
616 0 ▶ $detail = 0 unless defined $detail;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $detail 0 0 0
617 # Increment $detail if $verbosity > 0, unless $detail = -1,
618 0 ▶ if (($detail > -1) && ($VERBOSITY > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($detail > -1 and $LaTeXML::Common::Error::VERBOSITY > 0) 0 0 0
Condition0%0/3
$detail > -1 and $LaTeXML::Common::Error::VERBOSITY > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$detail > -1 and $LaTeXML::Common::Error::VERBOSITY > 0
$detail > -1 $LaTeXML::Common::Error::VERBOSITY > 0
Truth table0%0/3
A and B
A= $detail > -1B= $LaTeXML::Common::Error::VERBOSITY > 0
ABresult
0X0
100
111
619 0 ▶ $detail = 0 if defined $VERBOSITY && $VERBOSITY < -1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $LaTeXML::Common::Error::VERBOSITY and $LaTeXML::Common::Error::VERBOSITY < -1 0 0 0
Condition0%0/3
defined $LaTeXML::Common::Error::VERBOSITY and $LaTeXML::Common::Error::VERBOSITY < -1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $LaTeXML::Common::Error::VERBOSITY and $LaTeXML::Common::Error::VERBOSITY < -1
defined $LaTeXML::Common::Error::VERBOSITY $LaTeXML::Common::Error::VERBOSITY < -1
Truth table0%0/3
A and B
A= defined $LaTeXML::Common::Error::VERBOSITYB= $LaTeXML::Common::Error::VERBOSITY < -1
ABresult
0X0
100
111
620 0 ▶ $detail++ if defined $VERBOSITY && $VERBOSITY > +1; }
Branch: 1 branch
BranchTrueFalseTotal
if defined $LaTeXML::Common::Error::VERBOSITY and $LaTeXML::Common::Error::VERBOSITY > 1 0 0 0
Condition0%0/3
defined $LaTeXML::Common::Error::VERBOSITY and $LaTeXML::Common::Error::VERBOSITY > 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $LaTeXML::Common::Error::VERBOSITY and $LaTeXML::Common::Error::VERBOSITY > 1
defined $LaTeXML::Common::Error::VERBOSITY $LaTeXML::Common::Error::VERBOSITY > 1
Truth table0%0/3
A and B
A= defined $LaTeXML::Common::Error::VERBOSITYB= $LaTeXML::Common::Error::VERBOSITY > 1
ABresult
0X0
100
111
621  
622 # FIRST line of stack trace information ought to look at the $where
623 0 my $wheretype = ref $where;
624 0 ▶ if ($detail <= 0) { } # No extra context
Branch: 4 branches
BranchTrueFalseTotal
if ($detail <= 0) { } 0 0 0
elsif ($wheretype =~ /^XML::LibXML/) { } 0 0 0
elsif ($wheretype =~ /LaTeXML::Core::Gullet/) { } 0 0 0
elsif ($wheretype =~ /LaTeXML::Core::Stomach/) { } 0 0 0
625 elsif ($wheretype =~ /^XML::LibXML/) {
626 0 push(@lines, "Node is " . Stringify($where)); }
627 ## Hmm... if we're being verbose or level is high, we might do this:
628 ### "Currently in ".$doc->getInsertionContext); }
629 elsif ($wheretype =~ 'LaTeXML::Core::Gullet') {
630 0 push(@lines, $where->showUnexpected); } # Or better?
631 elsif ($wheretype =~ 'LaTeXML::Core::Stomach') {
632 push(@lines,
633 0 ▶ "Recently digested: " . join(' ', map { Stringify($_) } @LaTeXML::LIST))
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::Common::Error::VERBOSITY > 1 0 0 0
634 if $VERBOSITY > 1; }
635  
636 #----------------------------------------
637 # Add Stack Trace, if that seems worthwhile.
638 0 ▶ if (($detail > 1) && ($VERBOSITY > 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($detail > 1 and $LaTeXML::Common::Error::VERBOSITY > 0) { } 0 0 0
elsif ($detail > -1) { } 0 0 0
Condition0%0/3
$detail > 1 and $LaTeXML::Common::Error::VERBOSITY > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$detail > 1 and $LaTeXML::Common::Error::VERBOSITY > 0
$detail > 1 $LaTeXML::Common::Error::VERBOSITY > 0
Truth table0%0/3
A and B
A= $detail > 1B= $LaTeXML::Common::Error::VERBOSITY > 0
ABresult
0X0
100
111
639 0 push(@lines, "Stack Trace:", stacktrace()); }
640 elsif ($detail > -1) {
641 0 ▶ my $nstack = ($detail > 1 ? undef : ($detail > 0 ? 4 : 1));
Branch: 2 branches
BranchTrueFalseTotal
$detail > 1 ? : 0 0 0
$detail > 0 ? : 0 0 0
642 0 ▶ if (my @objects = objectStack($nstack)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@objects) = objectStack($nstack)) 0 0 0
643 0 my $top = shift(@objects);
644 0 push(@lines, "In " . trim(Stringify($$top[0])) . ' ' . Stringify($$top[1]));
645 0 ▶ push(@objects, ['...']) if @objects && defined $nstack;
Branch: 1 branch
BranchTrueFalseTotal
if @objects and defined $nstack 0 0 0
Condition0%0/3
@objects and defined $nstack
!ll&&!rl&&r
000
MC/DC0%0/2
@objects and defined $nstack
@objects defined $nstack
Truth table0%0/3
A and B
A= @objectsB= defined $nstack
ABresult
0X0
100
111
646 0 ▶ push(@lines, join('', (map { ' <= ' . trim(Stringify($$_[0])) } @objects))) if @objects;
Branch: 1 branch
BranchTrueFalseTotal
if @objects 0 0 0
647 } }
648  
649 # finally, join the result into a block of lines, indenting all but the 1st line.
650 0 return join("\n\t", @lines); }
651  
652 sub MergeStatus {
653 0 ▶ my ($external_state) = @_;
Subroutine MergeStatus: not called CC=7 SCAR=40.3
Pod undocumented
654 0 my $state = $STATE;
655 0 ▶ return unless $state && $external_state;
Branch: 1 branch
BranchTrueFalseTotal
unless $state and $external_state 0 0 0
Condition0%0/3
$state and $external_state
!ll&&!rl&&r
000
MC/DC0%0/2
$state and $external_state
$state $external_state
Truth table0%0/3
A and B
A= $stateB= $external_state
ABresult
0X0
100
111
656 0 my $status = $$state{status};
657 0 my $external_status = $$external_state{status};
658 # Should this be a state method? I suspect XS-ive conflicts later on...
659 0 foreach my $type (keys %$external_status) {
660 0 ▶ if ($type eq 'undefined' or $type eq 'missing') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'undefined' or $type eq 'missing') { } 0 0 0
Condition0%0/3
$type eq "undefined" or $type eq "missing"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "undefined" or $type eq "missing"
$type eq "undefined" $type eq "missing"
Truth table0%0/3
A or B
A= $type eq "undefined"B= $type eq "missing"
ABresult
1X1
011
000
661 0 my $table = $$external_status{$type};
662 0 foreach my $subtype (keys %$table) {
663 0 $$status{$type}{$subtype} += $$table{$subtype};
664 }
665 } else {
666 0 $$status{$type} += $$external_status{$type};
667 }
668 }
669 0 return; }
670  
671 # returns the locator of an object, or undef
672 sub Locator {
673 0 ▶ my ($object) = @_;
Subroutine Locator: not called CC=3 SCAR=24.8
Pod undocumented
674 0 ▶ return ($object && $object->can('getLocator') ? $object->getLocator : undef); }
Branch: 1 branch
BranchTrueFalseTotal
$object && $object->can('getLocator') ? : 0 0 0
Condition0%0/3
$object and $object->can("getLocator")
!ll&&!rl&&r
000
MC/DC0%0/2
$object and $object->can("getLocator")
$object $object->can("getLocator")
Truth table0%0/3
A and B
A= $objectB= $object->can("getLocator")
ABresult
0X0
100
111
675  
676 # A more organized abstraction along there likes of $where->whereAreYou
677 # might be useful?
678 sub getLocation {
679 0 ▶ my ($where) = @_;
Subroutine getLocation: not called CC=13 SCAR=52.0
Pod undocumented
680 0 my $wheretype = ref $where;
681 0 ▶ if ($wheretype && ($wheretype =~ /^XML::LibXML/)) {
Branch: 4 branches
BranchTrueFalseTotal
if ($wheretype and $wheretype =~ /^XML::LibXML/) { } 0 0 0
elsif ($wheretype and $where->can('getLocator')) { } 0 0 0
elsif (defined $where) { } 0 0 0
elsif ($LaTeXML::DOCUMENT) { } 0 0 0
Condition0%0/3
$wheretype and $wheretype =~ /^XML::LibXML/
!ll&&!rl&&r
000
MC/DC0%0/2
$wheretype and $wheretype =~ /^XML::LibXML/
$wheretype $wheretype =~ /^XML::LibXML/
Truth table0%0/3
A and B
A= $wheretypeB= $wheretype =~ /^XML::LibXML/
ABresult
0X0
100
111
682 0 ▶ my $box = $LaTeXML::DOCUMENT && $LaTeXML::DOCUMENT->getNodeBox($where);
Condition0%0/3
$LaTeXML::DOCUMENT && $LaTeXML::DOCUMENT->getNodeBox($where)
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::DOCUMENT && $LaTeXML::DOCUMENT->getNodeBox($where)
$LaTeXML::DOCUMENT $LaTeXML::DOCUMENT->getNodeBox($where)
Truth table0%0/3
A && B
A= $LaTeXML::DOCUMENTB= $LaTeXML::DOCUMENT->getNodeBox($where)
ABresult
0X0
100
111
683 0 ▶ return Locator($box) if $box; }
Branch: 1 branch
BranchTrueFalseTotal
if $box 0 0 0
684 ▶ elsif ($wheretype && $where->can('getLocator')) {
Condition0%0/3
$wheretype and $where->can("getLocator")
!ll&&!rl&&r
000
MC/DC0%0/2
$wheretype and $where->can("getLocator")
$wheretype $where->can("getLocator")
Truth table0%0/3
A and B
A= $wheretypeB= $where->can("getLocator")
ABresult
0X0
100
111
685 0 return $where->getLocator; }
686 elsif (defined $where) {
687 0 return $where; }
688 # Otherwise, try to guess where the error came from!
689 elsif ($LaTeXML::DOCUMENT) { # During construction?
690 0 my $node = $LaTeXML::DOCUMENT->getNode;
691 0 my $box = $LaTeXML::DOCUMENT->getNodeBox($node);
692 0 ▶ return Locator($box) if $box; }
Branch: 1 branch
BranchTrueFalseTotal
if $box 0 0 0
693 0 ▶ if ($LaTeXML::BOX) { # In constructor?
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::BOX) 0 0 0
694 0 return Locator($LaTeXML::BOX); }
695 0 ▶ if ($STATE && $STATE->getStomach) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::STATE and $LaTeXML::Common::Error::STATE->getStomach) 0 0 0
Condition0%0/3
$LaTeXML::Common::Error::STATE and $LaTeXML::Common::Error::STATE->getStomach
!ll&&!rl&&r
000
MC/DC0%0/2
$LaTeXML::Common::Error::STATE and $LaTeXML::Common::Error::STATE->getStomach
$LaTeXML::Common::Error::STATE $LaTeXML::Common::Error::STATE->getStomach
Truth table0%0/3
A and B
A= $LaTeXML::Common::Error::STATEB= $LaTeXML::Common::Error::STATE->getStomach
ABresult
0X0
100
111
696 0 my $gullet = $STATE->getStomach->getGullet;
697 # NOTE: Problems here.
698 # (1) With obsoleting Tokens as a Mouth, we can get pointless "Anonymous String" locators!
699 # (2) If gullet is the source, we probably want to include next token, etc or
700 0 return Locator($gullet); }
701 # # If in postprocessing
702 # if($LaTeXML::Post::PROCESSOR && $LaTeXML::Post::DOCUMENT){
703 # return 'in '. $LaTeXML::Post::PROCESSOR->getName
704 # . ' on '. $LaTeXML::Post::DOCUMENT->siteRelativeDestination; }
705 0 return; }
706  
707 sub callerName {
708 0 ▶ my ($frame) = @_;
Subroutine callerName: not called CC=2 SCAR=17.9
Pod undocumented
709 0 ▶ my %info = caller_info(($frame || 0) + 2);
Condition0%0/2
$frame || 0
l!l
00
MC/DC0%0/1
$frame || 0
$frame
Truth table0%0/2
A
A= $frame
Aresult
11
00
710 0 return $info{sub}; }
711  
712 sub callerInfo {
713 0 ▶ my ($frame) = @_;
Subroutine callerInfo: not called CC=2 SCAR=17.9
Pod undocumented
714 0 ▶ my %info = caller_info(($frame || 0) + 2);
Condition0%0/2
$frame || 0
l!l
00
MC/DC0%0/1
$frame || 0
$frame
Truth table0%0/2
A
A= $frame
Aresult
11
00
715 0 return "$info{call} @ $info{file} line $info{line}"; }
716  
717 #======================================================================
718 # This portion adapted from Carp; simplified (but hopefully still correct),
719 # allow stringify overload, handle methods, make more concise!
720 #======================================================================
721 32 my $MAXARGS = 8; # [CONSTANT]
722 32 my $MAXLEN = 40; # Or more? [CONSTANT]
723  
724 sub trim {
725 0 ▶ my ($string) = @_;
Subroutine trim: not called CC=3 SCAR=24.8
Pod undocumented
726 0 ▶ return $string unless defined $string;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 0 0 0
727 0 ▶ $string = substr($string, 0, $MAXLEN - 3) . "..." if (length($string) > $MAXLEN);
Branch: 1 branch
BranchTrueFalseTotal
if length $string > $MAXLEN 0 0 0
728 0 $string =~ s/\n/\x{240D}/gs; # symbol for CR
729 0 return $string; }
730  
731 sub caller_info {
732 0 ▶ my ($i) = @_;
Subroutine caller_info: not called CC=12 SCAR=50.5
Pod undocumented
733  
734 0 my (%info, @args);
735 0 { package DB;
736 0 @info{qw(package file line sub has_args wantarray evaltext is_require)}
737 = caller($i);
738 0 @args = @DB::args; }
739 0 ▶ return () unless defined $info{package};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info{"package"} 0 0 0
740 # Work out the effective sub name, or eval, or method ...
741 0 my $call = '';
742 0 ▶ if (defined $info{evaltext}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $info{'evaltext'}) { } 0 0 0
elsif ($info{'sub'} eq '(eval)') { } 0 0 0
743 0 my $eval = $info{evaltext};
744 0 ▶ if ($info{is_require}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info{'is_require'}) { } 0 0 0
745 0 $call = "require $eval"; }
746 else {
747 0 $eval =~ s/([\\\'])/\\$1/g;
748 0 $call = "eval '" . trim($eval) . "'"; } }
749 elsif ($info{sub} eq '(eval)') {
750 0 $call = "eval {...}"; }
751 else {
752 0 $call = $info{sub};
753 0 my $method = $call;
754 0 $method =~ s/^.*:://;
755 # If $arg[0] is blessed, and `can' do $method, then we'll guess it's a method call?
756 0 ▶ if ($info{has_args} && @args
Branch: 1 branch
BranchTrueFalseTotal
if ($info{"has_args"} and @args and ref $args[0] and not ref($args[0]) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/ and $args[0]->can($method)) 0 0 0
Condition0%0/12
$info{"has_args"} and @args and ref $args[0] and not ref($args[0]) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/ and $args[0]->can($method)
!ll&&!rl&&r
000
$info{"has_args"} and @args and ref $args[0] and not ref($args[0]) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/
!ll&&!rl&&r
000
$info{"has_args"} and @args and ref $args[0]
!ll&&!rl&&r
000
$info{"has_args"} and @args
!ll&&!rl&&r
000
MC/DC0%0/5
$info{"has_args"} and @args and ref $args[0] and not ref($args[0]) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/ and $args[0]->can($method)
$info{"has_args"} @args ref $args[0] not ref($args[0]) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/ $args[0]->can($method)
Truth table0%0/6
A and B and C and not(D) and E
A= $info{"has_args"}B= @argsC= ref $args[0]D= not ref($args[0]) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/E= $args[0]->can($method)
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
757 && ref $args[0] && ((ref $args[0]) !~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/)
758 && $args[0]->can($method)) {
759 0 $call = format_arg(shift(@args)) . "->" . $method; } }
760 # Append arguments, if any.
761 0 ▶ if ($info{has_args}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info{"has_args"}) 0 0 0
762 0 @args = map { format_arg($_) } @args;
763 0 ▶ if (@args > $MAXARGS) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args > $MAXARGS) 0 0 0
764 0 $#args = $MAXARGS; push(@args, '...'); }
765 0 $call .= '(' . join(',', @args) . ')'; }
766 0 $info{call} = $call;
767 0 return %info; }
768  
769 sub format_arg {
770 0 ▶ my ($arg) = @_;
Subroutine format_arg: not called CC=4 SCAR=30.0
Pod undocumented
771 0 ▶ if (not defined $arg) { $arg = 'undef'; }
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $arg) { } 0 0 0
elsif (ref $arg) { } 0 0 0
elsif ($arg =~ /^-?[\d.]+\z/) { } 0 0 0
772 0 elsif (ref $arg) { $arg = Stringify($arg); } # Allow overloaded stringify!
773 elsif ($arg =~ /^-?[\d.]+\z/) { } # Leave numbers alone.
774 else { # Otherwise, string, so quote
775 0 $arg =~ s/'/\\'/g; # Slashify '
776 0 $arg =~ s/([[:cntrl:]])/ "\\".chr(ord($1)+ord('A'))/ge;
777 0 $arg = "'$arg'" }
778 0 return trim($arg); }
779  
780 # Semi-traditional (but reformatted) stack trace
781 sub stacktrace {
782 0 ▶ my $frame = 0;
Subroutine stacktrace: not called CC=3 SCAR=24.8
Pod documented
783 0 my $trace = "";
784 0 ▶ while (my %info = caller_info($frame++)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(%info) = caller_info($frame++)) 0 0 0
785 0 ▶ next if $info{sub} =~ /^LaTeXML::Common::Error/;
Branch: 1 branch
BranchTrueFalseTotal
if $info{"sub"} =~ /^LaTeXML::Common::Error/ 0 0 0
786 ## $info{call} = '' if $info{sub} =~ /^LaTeXML::Common::Error::(?:Fatal|Error|Warn|Info)/;
787 0 $trace .= "\t$info{call} @ $info{file} line $info{line}\n"; }
788 0 return $trace; }
789  
790 # Extract blessed `interesting' objects on stack.
791 # Get a maximum of $maxdepth objects (if $maxdepth is defined).
792 sub objectStack {
793 0 ▶ my ($maxdepth) = @_;
Subroutine objectStack: not called CC=15 SCAR=54.8
Pod documented
794 0 my $frame = 0;
795 0 my @objects = ();
796 0 while (1) {
797 0 my (%info, @args);
798 0 { package DB;
799 0 @info{qw(package file line sub has_args wantarray evaltext is_require)} = caller($frame++);
800 0 @args = @DB::args; }
801 0 ▶ last unless defined $info{package};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info{"package"} 0 0 0
802 0 ▶ next if ($info{sub} eq '(eval)') || !$info{has_args} || !@args;
Branch: 1 branch
BranchTrueFalseTotal
if $info{"sub"} eq "(eval)" or not $info{"has_args"} or not @args 0 0 0
Condition0%0/6
$info{"sub"} eq "(eval)" or not $info{"has_args"} or not @args
l!l&&r!l&&!r
000
$info{"sub"} eq "(eval)" or not $info{"has_args"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$info{"sub"} eq "(eval)" or not $info{"has_args"} or not @args
$info{"sub"} eq "(eval)" not $info{"has_args"} not @args
Truth table0%0/4
A or not(B) or not(C)
A= $info{"sub"} eq "(eval)"B= not $info{"has_args"}C= not @args
ABCresult
1XX1
01X1
0011
0000
803 0 my $self = $args[0];
804 # If $arg[0] is blessed, and `can' do $method, then we'll guess it's a method call?
805 # We'll collect such objects provided they can ->getLocator
806 0 ▶ if ((ref $self) && ((ref $self) !~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and not ref($self) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/) 0 0 0
Condition0%0/3
ref $self and not ref($self) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self and not ref($self) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/
ref $self not ref($self) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/
Truth table0%0/3
A and not(B)
A= ref $selfB= not ref($self) =~ /^(?:SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE)$/
ABresult
0X0
100
111
807 0 my $method = $info{sub};
808 0 $method =~ s/^.*:://;
809 0 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 0 0 0
810 0 ▶ next if @objects && ($self eq $objects[-1][0]); # but don't duplicate
Branch: 1 branch
BranchTrueFalseTotal
if @objects and $self eq $objects[-1][0] 0 0 0
Condition0%0/3
@objects and $self eq $objects[-1][0]
!ll&&!rl&&r
000
MC/DC0%0/2
@objects and $self eq $objects[-1][0]
@objects $self eq $objects[-1][0]
Truth table0%0/3
A and B
A= @objectsB= $self eq $objects[-1][0]
ABresult
0X0
100
111
811 0 ▶ if ($self->can('getLocator')) { # Digestion object?
Branch: 2 branches
BranchTrueFalseTotal
if ($self->can('getLocator')) { } 0 0 0
elsif ($self->isa('LaTeXML::Post::Processor') or $self->isa('LaTeXML::Post::Document')) { } 0 0 0
812 0 push(@objects, [$self, Locator($self)]); }
813 ▶ elsif ($self->isa('LaTeXML::Post::Processor') || $self->isa('LaTeXML::Post::Document')) {
Condition0%0/3
$self->isa("LaTeXML::Post::Processor") or $self->isa("LaTeXML::Post::Document")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->isa("LaTeXML::Post::Processor") or $self->isa("LaTeXML::Post::Document")
$self->isa("LaTeXML::Post::Processor") $self->isa("LaTeXML::Post::Document")
Truth table0%0/3
A or B
A= $self->isa("LaTeXML::Post::Processor")B= $self->isa("LaTeXML::Post::Document")
ABresult
1X1
011
000
814 0 push(@objects, [$self, '->' . $method]); }
815 0 ▶ last if $maxdepth && (scalar(@objects) >= $maxdepth); } } }
Branch: 1 branch
BranchTrueFalseTotal
if $maxdepth and scalar @objects >= $maxdepth 0 0 0
Condition0%0/3
$maxdepth and scalar @objects >= $maxdepth
!ll&&!rl&&r
000
MC/DC0%0/2
$maxdepth and scalar @objects >= $maxdepth
$maxdepth scalar @objects >= $maxdepth
Truth table0%0/3
A and B
A= $maxdepthB= scalar @objects >= $maxdepth
ABresult
0X0
100
111
816 0 return @objects; }
817  
818 #**********************************************************************
819 32 1;
820  
821 __END__
« lib/LaTeXML/Core/State.pm ↑ Summary lib/LaTeXML/Util/Pathname.pm »