lib/LaTeXML/Core/State.pm

filter: Statementstmt 4.8% 20 / 417 Branchbran 0.0% 0 / 180 Conditioncond 0.0% 0 / 172 MC/DCmcdc 0.0% 0 / 93 Subroutinesub 7.9% 5 / 63 Podpod 29.8% 17 / 57 totaltotal 4.2% 42 / 982 CC 156 SCAR 52.7
CC
156
Cov
3%
getStatusMessage
930.0
assign_internal
380.0
lookupDigestableDefinition
210.0
CRAP 194.5
« lib/LaTeXML/Common/Glue.pm ↑ Summary lib/LaTeXML/Common/Error.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Core::State | #
3 # | Maintains state: bindings, values, grouping | #
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::Core::State;
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::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 32 ▶use LaTeXML::Core::Token; # To get CatCodes
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # Naming scheme for keys (such as it is)
20 # binding:<cs> : the definition associated with <cs>
21 # value:<name> : some data stored under <name>
22 # With TeX Registers/Parameters, the name begins with "\"
23 # internal:<name> : Some internally interesting state.
24  
25 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 # The State efficiently maintain the bindings in a TeX-like fashion.
27 # bindings associate data with keys (eg definitions with macro names)
28 # and respect TeX grouping; that is, an assignment is only in effect
29 # until the current group (opened by \bgroup) is closed (by \egroup).
30 #----------------------------------------------------------------------
31 # The objective is to make the following, most-common, operations FAST:
32 # begin & end a group (ie. push/pop a stack frame)
33 # lookup & assignment of values
34 # With the more obvious approach, a "stack of frames", either lookup would involve
35 # checking a sequence of frames until the current value is found;
36 # or, starting a new frame would involve copying bindings for all values
37 # I never quite studied how Knuth does it;
38 # The following structures allow these to be constant operations (usually),
39 # except for endgroup (which is linear in # of changed values in that frame).
40  
41 # There are 2 main structures used here.
42 # For each of several $table's (being "value", "meaning", "catcode" or other space of names),
43 # each table maintains the bound values, and "undo" defines the stack frames:
44 # $$self{$table}{$key} = [$current_value, $previous_value, ...]
45 # $$self{undo}[$frame]{$table}{$key} = (undef | $n)
46 # such that the "current value" associated with $key is the 0th element of the table array;
47 # the $previous_value's (if any) are values that had been assigned within previous groups.
48 # The undo list indicates how many values have been assigned for $key in
49 # the $frame'th frame (usually 0 is the one of interest).
50 # [Would be simpler to store boolean in undo, but see deactivateScope]
51 # [All keys fo $$self{undo}[$frame} are table names, EXCEPT "_FRAME_LOCK_"!!]
52 #
53 # So, in handwaving form, the algorithms are as follows:
54 # push-frame == bgroup == begingroup:
55 # push an empty hash {} onto the undo stack;
56 # pop-frame == egroup == endgroup:
57 # for the $n associated with every key in the topmost hash in the undo stack
58 # pop $n values from the table
59 # then remove the hash from the undo stack.
60 # Lookup value:
61 # we simply fetch the 0th element from the table
62 # Assign a value:
63 # local scope (the normal way):
64 # we push a new value into the table described above,
65 # and also increment the associated value in the undo stack
66 # global scope:
67 # remove any locally scoped values, and undo entries for the key
68 # then set the 0th (only remaining) value to the given one.
69 # named-scope $scope:
70 # push an entry [$table,$key,$value] globally to the 'stash' table's value.
71 # And assign locally, if the $scope is active (has non-zero value in stash_active table),
72 #
73 # There are tables for
74 # catcode: keys are char;
75 # Also, "math:$char" =1 when $char is active in math.
76 # mathcode, sfcode, lccode, uccode, delcode : are similar to catcode but store
77 # additional kinds codes per char (see TeX)
78 # value: keys are anything (typically a string, though) and value is the value associated with it
79 # meaning: The definition assocated with $key, usually a control-sequence.
80 # stash & stash_active: support named scopes
81 # (see also activateScope & deactivateScope)
82 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83  
84 # options:
85 # catcodes => (standard|style|none)
86 # stomach => a Stomach object.
87 # model => a Mod el object.
88 sub new {
89 0 ▶ my ($class, %options) = @_;
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
90 my $self = bless { # table => {},
91 value => {}, meaning => {}, stash => {}, stash_active => {},
92 catcode => {}, mathcode => {}, sfcode => {}, lccode => {}, uccode => {}, delcode => {},
93 undo => [{ _FRAME_LOCK_ => 1 }], prefixes => {}, status => {},
94 0 stomach => $options{stomach}, model => $options{model} }, $class;
95 # Note that "100" is hardwired into TeX, The Program!!!
96 0 $$self{value}{MAX_ERRORS} = [100];
97 # Standard TeX units, in scaled points
98 $$self{value}{UNITS} = [{
99 0 pt => 65536, pc => 12 * 65536, in => 72.27 * 65536, bp => 72.27 * 65536 / 72,
100 cm => 72.27 * 65536 / 2.54, mm => 72.27 * 65536 / 2.54 / 10, dd => 1238 * 65536 / 1157,
101 cc => 12 * 1238 * 65536 / 1157, sp => 1,
102 px => 72.27 * 65536 / 72, # Assume px=bp ?
103 }];
104  
105 0 ▶ $options{catcodes} = 'standard' unless defined $options{catcodes};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options{"catcodes"} 0 0 0
106 0 ▶ if ($options{catcodes} =~ /^(standard|style)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"catcodes"} =~ /^(standard|style)/) 0 0 0
107 # Setup default catcodes.
108 0 my %std = ("\\" => CC_ESCAPE, "{" => CC_BEGIN, "}" => CC_END, "\$" => CC_MATH,
109 "&" => CC_ALIGN, "\r" => CC_EOL, "#" => CC_PARAM, "^" => CC_SUPER,
110 "_" => CC_SUB, " " => CC_SPACE, "\t" => CC_SPACE, "%" => CC_COMMENT,
111 "~" => CC_ACTIVE, chr(0) => CC_ESCAPE, "\f" => CC_ACTIVE);
112 0 map { $$self{catcode}{$_} = [$std{$_}] } keys %std;
113 0 ▶ for (my $c = ord('A') ; $c <= ord('Z') ; $c++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c <= 90) 0 0 0
114 0 $$self{catcode}{ chr($c) } = [CC_LETTER];
115 0 $$self{catcode}{ chr($c + ord('a') - ord('A')) } = [CC_LETTER]; }
116 }
117 0 $$self{value}{SPECIALS} = [['^', '_', '~', '&', '$', '#', "'"]];
118 0 ▶ if ($options{catcodes} eq 'style') {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"catcodes"} eq "style") 0 0 0
119 0 $$self{catcode}{'@'} = [CC_LETTER]; }
120 0 $$self{mathcode} = {};
121 0 $$self{sfcode} = {};
122 0 $$self{lccode} = {};
123 0 $$self{uccode} = {};
124 0 $$self{delcode} = {};
125 0 $$self{tracing_definitions} = {};
126 0 return $self; }
127  
128 sub assign_internal {
129 0 ▶ my ($self, $table, $key, $value, $scope) = @_;
Subroutine assign_internal: not called CC=19 SCAR=59.4
Pod undocumented
130 # hotcode lookupDefinition for \globaldefs,
131 # since this is called extremely often and should be highly standardized
132 0 ▶ if (my $globaldefs = $$self{value}{'\globaldefs'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $globaldefs = $self->{"value"}{"\\globaldefs"}) 0 0 0
133 0 ▶ if (my $global_value = $$globaldefs[0][0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $global_value = $globaldefs->[0][0]) 0 0 0
134 # magic TeX register override: \globaldefs
135 0 ▶ if ($global_value == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($global_value == 1) { } 0 0 0
elsif ($global_value == -1) { } 0 0 0
136 0 $scope = 'global'; }
137 elsif ($global_value == -1) {
138 0 $scope = 'local'; } } }
139 0 ▶ $scope = ($$self{prefixes}{global} ? 'global' : 'local') unless defined $scope;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $scope 0 0 0
$self->{'prefixes'}{'global'} ? : 0 0 0
140 0 ▶ if (exists $$self{tracing_definitions}{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"tracing_definitions"}{$key}) 0 0 0
141 0 ▶ Debug("ASSIGN $key in $table " . ($scope ? "($scope)" : '') . " => " .
Branch: 2 branches
BranchTrueFalseTotal
$scope ? : 0 0 0
ref $value ? : 0 0 0
142 (ref $value ? $value->stringify : $value)); }
143 0 ▶ if ($scope eq 'global') {
Branch: 2 branches
BranchTrueFalseTotal
if ($scope eq 'global') { } 0 0 0
elsif ($scope eq 'local') { } 0 0 0
144 # Remove bindings made in all frames down-to & including the next lower locked frame
145 0 my $frame;
146 0 my @frames = @{ $$self{undo} };
147 0 ▶ while (@frames) {
Branch: 1 branch
BranchTrueFalseTotal
if (@frames) 0 0 0
148 0 $frame = shift(@frames);
149 0 ▶ if (my $n = $$frame{$table}{$key}) { # Undo the bindings, if $key was bound in this frame
Branch: 1 branch
BranchTrueFalseTotal
if (my $n = $frame->{$table}{$key}) 0 0 0
150 0 ▶ map { shift(@{ $$self{$table}{$key} }) } 1 .. $n if $n;
Branch: 1 branch
BranchTrueFalseTotal
if $n 0 0 0
151 0 delete $$frame{$table}{$key}; }
152 0 ▶ last if $$frame{_FRAME_LOCK_}; }
Branch: 1 branch
BranchTrueFalseTotal
if $frame->{"_FRAME_LOCK_"} 0 0 0
153 # whatever is left -- if anything -- should be bindings below the locked frame.
154 0 $$frame{$table}{$key} = 1; # Note that there's only one value in the stack, now
155 0 unshift(@{ $$self{$table}{$key} }, $value); }
156 elsif ($scope eq 'local') {
157 0 ▶ if ($$self{undo}[0]{$table}{$key}) { # If the value was previously assigned in this frame
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'undo'}[0]{$table}{$key}) { } 0 0 0
158 0 $$self{$table}{$key}[0] = $value; } # Simply replace the value
159 else { # Otherwise, push new value & set 1 to be undone
160 0 $$self{undo}[0]{$table}{$key} = 1;
161 0 unshift(@{ $$self{$table}{$key} }, $value); } } # And push new binding.
162 else {
163 0 ▶ assign_internal($self, 'stash', $scope, [], 'global') unless $$self{stash}{$scope}[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"stash"}{$scope}[0] 0 0 0
164 0 push(@{ $$self{stash}{$scope}[0] }, [$table, $key, $value]);
165 assign_internal($self, $table, $key, $value, 'local')
166 0 ▶ if $$self{stash_active}{$scope}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"stash_active"}{$scope}[0] 0 0 0
167 0 return; }
168  
169 #======================================================================
170 sub getStomach {
171 0 ▶ my ($self) = @_;
Subroutine getStomach: not called CC=1 SCAR=6.9
Pod documented
172 0 return $$self{stomach}; }
173  
174 sub getModel {
175 0 ▶ my ($self) = @_;
Subroutine getModel: not called CC=1 SCAR=6.9
Pod documented
176 0 return $$self{model}; }
177  
178 #======================================================================
179  
180 # Lookup & assign a general Value
181 # [Note that the more direct $$self{value}{$_[1]}[0]; works, but creates entries
182 # this could concievably cause space issues, but timing doesn't show improvements this way]
183 sub lookupValue {
184 0 ▶ my ($self, $key) = @_;
Subroutine lookupValue: not called CC=2 SCAR=17.9
Pod documented
185 0 my $e = $$self{value}{$key};
186 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
187  
188 sub assignValue {
189 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignValue: not called CC=1 SCAR=6.9
Pod documented
190 0 assign_internal($self, 'value', $key, $value, $scope);
191 0 return; }
192  
193 # manage a (global) list of values
194 sub pushValue {
195 0 ▶ my ($self, $key, @values) = @_;
Subroutine pushValue: not called CC=2 SCAR=17.9
Pod documented
196 0 my $vtable = $$self{value};
197 0 ▶ assign_internal($self, 'value', $key, [], 'global') unless $$vtable{$key}[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $vtable->{$key}[0] 0 0 0
198 0 push(@{ $$vtable{$key}[0] }, @values);
199 0 return; }
200  
201 sub popValue {
202 0 ▶ my ($self, $key) = @_;
Subroutine popValue: not called CC=2 SCAR=17.9
Pod undocumented
203 0 my $vtable = $$self{value};
204 0 ▶ assign_internal($self, 'value', $key, [], 'global') unless $$vtable{$key}[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $vtable->{$key}[0] 0 0 0
205 0 return pop(@{ $$vtable{$key}[0] }); }
206  
207 sub unshiftValue {
208 0 ▶ my ($self, $key, @values) = @_;
Subroutine unshiftValue: not called CC=2 SCAR=17.9
Pod undocumented
209 0 my $vtable = $$self{value};
210 0 ▶ assign_internal($self, 'value', $key, [], 'global') unless $$vtable{$key}[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $vtable->{$key}[0] 0 0 0
211 0 unshift(@{ $$vtable{$key}[0] }, @values);
212 0 return; }
213  
214 sub shiftValue {
215 0 ▶ my ($self, $key) = @_;
Subroutine shiftValue: not called CC=2 SCAR=17.9
Pod undocumented
216 0 my $vtable = $$self{value};
217 0 ▶ assign_internal($self, 'value', $key, [], 'global') unless $$vtable{$key}[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $vtable->{$key}[0] 0 0 0
218 0 return shift(@{ $$vtable{$key}[0] }); }
219  
220 # manage a (global) hash of values
221 sub lookupMapping {
222 0 ▶ my ($self, $map, $key) = @_;
Subroutine lookupMapping: not called CC=2 SCAR=17.9
Pod undocumented
223 0 my $vtable = $$self{value};
224 0 my $mapping = $$vtable{$map}[0];
225 0 ▶ return ($mapping ? $$mapping{$key} : undef); }
Branch: 1 branch
BranchTrueFalseTotal
$mapping ? : 0 0 0
226  
227 sub assignMapping {
228 0 ▶ my ($self, $map, $key, $value) = @_;
Subroutine assignMapping: not called CC=3 SCAR=24.8
Pod undocumented
229 0 my $vtable = $$self{value};
230 0 ▶ assign_internal($self, 'value', $map, {}, 'global') unless $$vtable{$map}[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $vtable->{$map}[0] 0 0 0
231 0 ▶ if (!defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
232 0 delete $$vtable{$map}[0]{$key}; }
233 else {
234 0 $$vtable{$map}[0]{$key} = $value; }
235 0 return; }
236  
237 sub lookupMappingKeys {
238 0 ▶ my ($self, $map) = @_;
Subroutine lookupMappingKeys: not called CC=2 SCAR=17.9
Pod undocumented
239 0 my $vtable = $$self{value};
240 0 my $mapping = $$vtable{$map}[0];
241 0 ▶ return ($mapping ? sort keys %$mapping : ()); }
Branch: 1 branch
BranchTrueFalseTotal
$mapping ? : 0 0 0
242  
243 sub lookupStackedValues {
244 0 ▶ my ($self, $key) = @_;
Subroutine lookupStackedValues: not called CC=2 SCAR=17.9
Pod undocumented
245 0 my $stack = $$self{value}{$key};
246 0 ▶ return ($stack ? @$stack : ()); }
Branch: 1 branch
BranchTrueFalseTotal
$stack ? : 0 0 0
247  
248 #======================================================================
249 # Was $name bound? If $frame is given, check only whether it is bound in
250 # that frame (0 is the topmost).
251 sub isValueBound {
252 0 ▶ my ($self, $key, $frame) = @_;
Subroutine isValueBound: not called CC=2 SCAR=17.9
Pod undocumented
253 return (defined $frame ? $$self{undo}[$frame]{value}{$key}
254 0 ▶ : defined $$self{value}{$key}[0]); }
Branch: 1 branch
BranchTrueFalseTotal
defined $frame ? : 0 0 0
255  
256 sub valueInFrame {
257 0 ▶ my ($self, $key, $frame) = @_;
Subroutine valueInFrame: not called CC=4 SCAR=30.0
Pod undocumented
258 0 ▶ $frame = 0 unless defined $frame;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $frame 0 0 0
259 0 my $p = 0;
260 0 ▶ for (my $f = 0 ; $f < $frame ; $f++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f < $frame) 0 0 0
261 0 ▶ $p += $$self{undo}[$f]{value}{$key} || 0; }
Condition0%0/2
$self->{'undo'}[$f]{'value'}{$key} || 0
l!l
00
MC/DC0%0/1
$self->{'undo'}[$f]{'value'}{$key} || 0
$self->{'undo'}[$f]{'value'}{$key}
Truth table0%0/2
A
A= $self->{'undo'}[$f]{'value'}{$key}
Aresult
11
00
262 0 return $$self{value}{$key}[$p]; }
263  
264 #======================================================================
265 # Lookup & assign a character's Catcode
266 sub lookupCatcode {
267 0 ▶ my ($self, $key) = @_;
Subroutine lookupCatcode: not called CC=2 SCAR=17.9
Pod documented
268 0 my $e = $$self{catcode}{$key};
269 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
270  
271 sub assignCatcode {
272 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignCatcode: not called CC=1 SCAR=6.9
Pod documented
273 0 assign_internal($self, 'catcode', $key, $value, $scope);
274 0 return; }
275  
276 # The following rarely used.
277 sub lookupMathcode {
278 0 ▶ my ($self, $key) = @_;
Subroutine lookupMathcode: not called CC=2 SCAR=17.9
Pod undocumented
279 0 my $e = $$self{mathcode}{$key};
280 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
281  
282 sub assignMathcode {
283 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignMathcode: not called CC=1 SCAR=6.9
Pod undocumented
284 0 assign_internal($self, 'mathcode', $key, $value, $scope);
285 0 return; }
286  
287 sub lookupSFcode {
288 0 ▶ my ($self, $key) = @_;
Subroutine lookupSFcode: not called CC=2 SCAR=17.9
Pod undocumented
289 0 my $e = $$self{sfcode}{$key};
290 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
291  
292 sub assignSFcode {
293 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignSFcode: not called CC=1 SCAR=6.9
Pod undocumented
294 0 assign_internal($self, 'sfcode', $key, $value, $scope);
295 0 return; }
296  
297 sub lookupLCcode {
298 0 ▶ my ($self, $key) = @_;
Subroutine lookupLCcode: not called CC=2 SCAR=17.9
Pod undocumented
299 0 my $e = $$self{lccode}{$key};
300 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
301  
302 sub assignLCcode {
303 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignLCcode: not called CC=1 SCAR=6.9
Pod undocumented
304 0 assign_internal($self, 'lccode', $key, $value, $scope);
305 0 return; }
306  
307 sub lookupUCcode {
308 0 ▶ my ($self, $key) = @_;
Subroutine lookupUCcode: not called CC=2 SCAR=17.9
Pod undocumented
309 0 my $e = $$self{uccode}{$key};
310 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
311  
312 sub assignUCcode {
313 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignUCcode: not called CC=1 SCAR=6.9
Pod undocumented
314 0 assign_internal($self, 'uccode', $key, $value, $scope);
315 0 return; }
316  
317 sub lookupDelcode {
318 0 ▶ my ($self, $key) = @_;
Subroutine lookupDelcode: not called CC=2 SCAR=17.9
Pod undocumented
319 0 my $e = $$self{delcode}{$key};
320 0 ▶ return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
321  
322 sub assignDelcode {
323 0 ▶ my ($self, $key, $value, $scope) = @_;
Subroutine assignDelcode: not called CC=1 SCAR=6.9
Pod undocumented
324 0 assign_internal($self, 'delcode', $key, $value, $scope);
325 0 return; }
326  
327 #======================================================================
328 # Specialized versions of lookup & assign for dealing with definitions
329  
330 32 our @CATCODE_ACTIVE_OR_CS = (
331 0, 0, 0, 0,
332 0, 0, 0, 0,
333 0, 0, 0, 0,
334 0, 1, 0, 0,
335 1, 0, 0, 0);
336 32 our @CATCODE_LETTER_OR_OTHER = (
337 0, 0, 0, 0,
338 0, 0, 0, 0,
339 0, 0, 0, 1,
340 1, 0, 0, 0,
341 0, 0, 0, 0);
342  
343 # Get the `Meaning' of a token. For active control sequence's
344 # this may give the definition object (if defined) or another token (if \let) or undef
345 # Any other token is returned as is.
346 sub lookupMeaning {
347 0 ▶ my ($self, $token) = @_;
Subroutine lookupMeaning: not called CC=6 SCAR=37.4
Pod documented
348 0 ▶ if (my $cs = $token
Branch: 1 branch
BranchTrueFalseTotal
if (my $cs = $token && $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] && !$token->[2] && $token->[0]) { } 0 0 0
Condition0%0/9
$token && $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] && !$token->[2] && $token->[0]
!ll&&!rl&&r
000
$token and $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and not $token->[2]
!ll&&!rl&&r
000
$token and $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]]
!ll&&!rl&&r
000
MC/DC0%0/4
$token && $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] && !$token->[2] && $token->[0]
$token $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] not $token->[2] $token->[0]
Truth table0%0/5
A and B and not(C) && D
A= $tokenB= $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]]C= not $token->[2]D= $token->[0]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
349 && $CATCODE_ACTIVE_OR_CS[$$token[1]]
350 && !$$token[2] # return token itself, if \noexpand
351 && $$token[0]) {
352 0 ▶ my $e = $$self{meaning}{$cs}; return $e && $$e[0]; }
Condition0%0/3
$e && $e->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$e && $e->[0]
$e $e->[0]
Truth table0%0/3
A && B
A= $eB= $e->[0]
ABresult
0X0
100
111
353 0 else { return $token; } }
354  
355 # $meaning should be a definition (for defining active control sequences)
356 # or another token, for \let
357 sub assignMeaning {
358 0 ▶ my ($self, $token, $meaning, $scope) = @_;
Subroutine assignMeaning: not called CC=2 SCAR=17.9
Pod documented
359 0 ▶ return if $token->equals($meaning); # HACK!!!????
Branch: 1 branch
BranchTrueFalseTotal
if $token->equals($meaning) 0 0 0
360 0 assign_internal($self, 'meaning', $token->getCSName => $meaning, $scope);
361 0 return; }
362  
363 # used for expansion & various queries
364 # Since we're not doing digestion here, we don't need to handle mathactive,
365 # nor cs let to executable tokens
366 # This returns a definition object, or undef
367  
368 # merge of @CATCODE_EXECUTABLE & @CATCODE_PRIMITIVE_NAME
369 32 our @CATCODE_EXECUTABLE_PRIMITIVE_NAME = ( # [CONSTANT]
370 undef, 'Begin', 'End', 'Math',
371 'Align', undef, undef, 'Superscript',
372 'Subscript', undef, undef, undef,
373 undef, undef, undef, undef,
374 undef, undef, undef, undef);
375  
376 sub lookupDefinition {
377 0 ▶ my ($self, $token) = @_;
Subroutine lookupDefinition: not called CC=7 SCAR=40.3
Pod undocumented
378 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
379 0 my $defn;
380 my $entry;
381 # my $inmath = $self->lookupValue('IN_MATH');
382 0 my $cc = $$token[1];
383 0 ▶ my $lookupname =
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] ? : 0 0 0
384 ($CATCODE_ACTIVE_OR_CS[$cc]
385 ? $$token[0]
386 : $CATCODE_EXECUTABLE_PRIMITIVE_NAME[$cc]);
387 0 ▶ if ($lookupname
Branch: 1 branch
BranchTrueFalseTotal
if ($lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token") 0 0 0
Condition0%0/9
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token"
!ll&&!rl&&r
000
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0]
!ll&&!rl&&r
000
$lookupname and $entry = $self->{"meaning"}{$lookupname}
!ll&&!rl&&r
000
MC/DC0%0/4
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token"
$lookupname $entry = $self->{"meaning"}{$lookupname} $defn = $entry->[0] ref $defn ne "LaTeXML::Core::Token"
Truth table0%0/5
A and B and C and D
A= $lookupnameB= $entry = $self->{"meaning"}{$lookupname}C= $defn = $entry->[0]D= ref $defn ne "LaTeXML::Core::Token"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
388 && ($entry = $$self{meaning}{$lookupname})
389 && ($defn = $$entry[0])
390 # Can only be a token or definition; we want defns!
391 && ((ref $defn) ne 'LaTeXML::Core::Token')) {
392 0 return $defn; }
393 0 return; }
394  
395 # identical, but for return test; used by skipConditionalBody
396 sub lookupConditional {
397 0 ▶ my ($self, $token) = @_;
Subroutine lookupConditional: not called CC=6 SCAR=37.4
Pod undocumented
398 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
399 0 my $defn;
400 my $entry;
401 0 ▶ if ($CATCODE_ACTIVE_OR_CS[$$token[1]]
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token") 0 0 0
Condition0%0/9
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token"
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0]
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]}
!ll&&!rl&&r
000
MC/DC0%0/4
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token"
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] $entry = $self->{"meaning"}{$token->[0]} $defn = $entry->[0] ref $defn ne "LaTeXML::Core::Token"
Truth table0%0/5
A and B and C and D
A= $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]]B= $entry = $self->{"meaning"}{$token->[0]}C= $defn = $entry->[0]D= ref $defn ne "LaTeXML::Core::Token"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
402 && ($entry = $$self{meaning}{ $$token[0] })
403 && ($defn = $$entry[0])
404 # Can only be a token or definition; we only want defns that have conditional_type
405 && ((ref $defn) ne 'LaTeXML::Core::Token')) {
406 0 return $$defn{conditional_type}; }
407 0 return; }
408  
409 # Identical but inlined return tests for efficiency; used by readXToken
410 sub lookupExpandable {
411 0 ▶ my ($self, $token, $toplevel) = @_;
Subroutine lookupExpandable: not called CC=9 SCAR=45.0
Pod undocumented
412 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
413 0 my $defn;
414 my $entry;
415 0 ▶ if ($CATCODE_ACTIVE_OR_CS[$$token[1]]
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"} and $toplevel || !$defn->{"isProtected"}) 0 0 0
Condition0%0/18
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"} and $toplevel || !$defn->{"isProtected"}
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"}
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token"
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0]
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]}
!ll&&!rl&&r
000
$toplevel or not $defn->{"isProtected"}
l!l&&r!l&&!r
000
MC/DC0%0/7
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] and $entry = $self->{"meaning"}{$token->[0]} and $defn = $entry->[0] and ref $defn ne "LaTeXML::Core::Token" and $defn->{"isExpandable"} and $toplevel || !$defn->{"isProtected"}
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] $entry = $self->{"meaning"}{$token->[0]} $defn = $entry->[0] ref $defn ne "LaTeXML::Core::Token" $defn->{"isExpandable"} $toplevel not $defn->{"isProtected"}
Truth table0%0/8
A and B and C and D and E and F or not(G)
A= $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]]B= $entry = $self->{"meaning"}{$token->[0]}C= $defn = $entry->[0]D= ref $defn ne "LaTeXML::Core::Token"E= $defn->{"isExpandable"}F= $toplevelG= not $defn->{"isProtected"}
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11110XX0
11111000
111111X1
11111011
416 && ($entry = $$self{meaning}{ $$token[0] })
417 && ($defn = $$entry[0])
418 # Can only be a token or definition; we want defns!
419 && ((ref $defn) ne 'LaTeXML::Core::Token')
420 && $$defn{isExpandable}
421 && ($toplevel || !$$defn{isProtected})) { # is this the right logic here? don't expand unless digesting?
422 0 return $defn; }
423 0 return; }
424  
425 # Whether token must be wrapped as dont_expand
426 sub isDontExpandable {
427 0 ▶ my ($self, $token) = @_;
Subroutine isDontExpandable: not called CC=7 SCAR=40.3
Pod undocumented
428 # Basically: a CS or Active token that is either not defined, or is expandable
429 # (but not \let to a token)
430 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
431 0 my $defn;
432 my $entry;
433 # my $inmath = $self->lookupValue('IN_MATH');
434 0 my $cc = $$token[1];
435 0 ▶ if ($CATCODE_ACTIVE_OR_CS[$cc]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc]) 0 0 0
436 0 my $lookupname = $$token[0];
437 0 ▶ if ($lookupname
Branch: 1 branch
BranchTrueFalseTotal
if ($lookupname and $entry = $self->{'meaning'}{$lookupname} and $defn = $entry->[0]) { } 0 0 0
Condition0%0/6
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0]
!ll&&!rl&&r
000
$lookupname and $entry = $self->{"meaning"}{$lookupname}
!ll&&!rl&&r
000
MC/DC0%0/3
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0]
$lookupname $entry = $self->{"meaning"}{$lookupname} $defn = $entry->[0]
Truth table0%0/4
A and B and C
A= $lookupnameB= $entry = $self->{"meaning"}{$lookupname}C= $defn = $entry->[0]
ABCresult
0XX0
10X0
1100
1111
438 && ($entry = $$self{meaning}{$lookupname})
439 && ($defn = $$entry[0])) {
440 0 ▶ return ((ref $defn) ne 'LaTeXML::Core::Token') && $$defn{isExpandable}; }
Condition0%0/3
ref $defn ne 'LaTeXML::Core::Token' && $defn->{'isExpandable'}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $defn ne 'LaTeXML::Core::Token' && $defn->{'isExpandable'}
ref $defn ne 'LaTeXML::Core::Token' $defn->{'isExpandable'}
Truth table0%0/3
A && B
A= ref $defn ne 'LaTeXML::Core::Token'B= $defn->{'isExpandable'}
ABresult
0X0
100
111
441 else {
442 0 return 1; } }
443 0 return; }
444  
445 # used for digestion
446 # This recognizes mathactive tokens in math mode
447 # and also looks for cs that have been let to other `executable' tokens
448 # This returns a definition object,
449 # or a "self inserting" token.
450 sub lookupDigestableDefinition {
451 0 ▶ my ($self, $token) = @_;
Subroutine lookupDigestableDefinition: not called CC=14 SCAR=53.5
Pod undocumented
452 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
453 0 my $defn;
454 my $entry;
455 # my $inmath = $self->lookupValue('IN_MATH');
456 0 my $cc = $$token[1];
457 0 my $name = $$token[0];
458 0 ▶ my $lookupname =
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] || $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] && $self->lookupValue('IN_MATH') && ($self->lookupMathcode($name) || 0) == 32768 ? : 0 0 0
Condition0%0/11
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] or $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] and $self->lookupValue("IN_MATH") and ($self->lookupMathcode($name) || 0) == 32768
l!l&&r!l&&!r
000
$LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] and $self->lookupValue("IN_MATH") and ($self->lookupMathcode($name) || 0) == 32768
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] and $self->lookupValue("IN_MATH")
!ll&&!rl&&r
000
$self->lookupMathcode($name) || 0
l!l
00
MC/DC0%0/4
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] or $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] and $self->lookupValue("IN_MATH") and ($self->lookupMathcode($name) || 0) == 32768
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] $self->lookupValue("IN_MATH") $self->lookupMathcode($name)
Truth table0%0/5
A or B and C and D
A= $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc]B= $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc]C= $self->lookupValue("IN_MATH")D= $self->lookupMathcode($name)
ABCDresult
1XXX1
01111
00XX0
010X0
01100
459 (($CATCODE_ACTIVE_OR_CS[$cc]
460 || ($CATCODE_LETTER_OR_OTHER[$cc] && $self->lookupValue('IN_MATH')
461 && (($self->lookupMathcode($name) || 0) == 0x8000)))
462 ? $name
463 : $CATCODE_EXECUTABLE_PRIMITIVE_NAME[$cc]);
464 0 ▶ if ($lookupname && ($entry = $$self{meaning}{$lookupname})
Branch: 1 branch
BranchTrueFalseTotal
if ($lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0]) 0 0 0
Condition0%0/6
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0]
!ll&&!rl&&r
000
$lookupname and $entry = $self->{"meaning"}{$lookupname}
!ll&&!rl&&r
000
MC/DC0%0/3
$lookupname and $entry = $self->{"meaning"}{$lookupname} and $defn = $entry->[0]
$lookupname $entry = $self->{"meaning"}{$lookupname} $defn = $entry->[0]
Truth table0%0/4
A and B and C
A= $lookupnameB= $entry = $self->{"meaning"}{$lookupname}C= $defn = $entry->[0]
ABCresult
0XX0
10X0
1100
1111
465 && ($defn = $$entry[0])) {
466 # If a cs has been let to an executable token, lookup ITS defn.
467 0 ▶ if (((ref $defn) eq 'LaTeXML::Core::Token')
Branch: 2 branches
BranchTrueFalseTotal
if (ref $defn eq "LaTeXML::Core::Token" and $lookupname = $defn->[2] ? "\\relax" : $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]] and $entry = $self->{"meaning"}{$lookupname}) 0 0 0
$defn->[2] ? : 0 0 0
Condition0%0/6
ref $defn eq "LaTeXML::Core::Token" and $lookupname = $defn->[2] ? "\\relax" : $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]] and $entry = $self->{"meaning"}{$lookupname}
!ll&&!rl&&r
000
ref $defn eq "LaTeXML::Core::Token" and $lookupname = $defn->[2] ? "\\relax" : $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]]
!ll&&!rl&&r
000
MC/DC0%0/3
ref $defn eq "LaTeXML::Core::Token" and $lookupname = $defn->[2] ? "\\relax" : $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]] and $entry = $self->{"meaning"}{$lookupname}
ref $defn eq "LaTeXML::Core::Token" $lookupname = $defn->[2] ? "\\relax" : $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]] $entry = $self->{"meaning"}{$lookupname}
Truth table0%0/4
A and B and C
A= ref $defn eq "LaTeXML::Core::Token"B= $lookupname = $defn->[2] ? "\\relax" : $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]]C= $entry = $self->{"meaning"}{$lookupname}
ABCresult
0XX0
10X0
1100
1111
468 # If we're digesting an unexpanded, act like \relax
469 && ($lookupname = ($$defn[2] ? '\relax' : $CATCODE_EXECUTABLE_PRIMITIVE_NAME[$$defn[1]]))
470 && ($entry = $$self{meaning}{$lookupname})) {
471 0 $defn = $$entry[0]; }
472 0 return $defn; }
473 0 return $token; }
474  
475 # And a shorthand for installing definitions
476 sub installDefinition {
477 0 ▶ my ($self, $definition, $scope) = @_;
Subroutine installDefinition: not called CC=7 SCAR=40.3
Pod documented
478 # Locked definitions!!! (or should this test be in assignMeaning?)
479 # Ignore attempts to (re)define $cs from tex sources
480 # my $cs = $definition->getCS->getCSName;
481 0 my $token = $definition->getCS;
482 0 ▶ my $cs = ($LaTeXML::Core::Token::CATCODE_PRIMITIVE_NAME[$$token[1]] || $$token[0]);
Condition0%0/3
$LaTeXML::Core::Token::CATCODE_PRIMITIVE_NAME[$token->[1]] || $token->[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$LaTeXML::Core::Token::CATCODE_PRIMITIVE_NAME[$token->[1]] || $token->[0]
$LaTeXML::Core::Token::CATCODE_PRIMITIVE_NAME[$token->[1]] $token->[0]
Truth table0%0/3
A || B
A= $LaTeXML::Core::Token::CATCODE_PRIMITIVE_NAME[$token->[1]]B= $token->[0]
ABresult
1X1
011
000
483 0 ▶ if ($self->lookupValue("$cs:locked") && !$LaTeXML::Core::State::UNLOCKED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lookupValue("${cs}:locked") and not $LaTeXML::Core::State::UNLOCKED) 0 0 0
Condition0%0/3
$self->lookupValue("${cs}:locked") and not $LaTeXML::Core::State::UNLOCKED
!ll&&!rl&&r
000
MC/DC0%0/2
$self->lookupValue("${cs}:locked") and not $LaTeXML::Core::State::UNLOCKED
$self->lookupValue("${cs}:locked") not $LaTeXML::Core::State::UNLOCKED
Truth table0%0/3
A and not(B)
A= $self->lookupValue("${cs}:locked")B= not $LaTeXML::Core::State::UNLOCKED
ABresult
0X0
100
111
484 0 my $s = $self->getStomach->getGullet->getSource;
485 # report if the redefinition seems to come from document source
486 0 ▶ if (((!defined($s)) || ($s =~ /\.(tex|bib)$/))
Branch: 1 branch
BranchTrueFalseTotal
if (!defined($s) || $s =~ /\.(tex|bib)$/ and not $s =~ /\.code\.tex$/) 0 0 0
Condition0%0/6
!defined($s) || $s =~ /\.(tex|bib)$/ and not $s =~ /\.code\.tex$/
!ll&&!rl&&r
000
not defined $s or $s =~ /\.(tex|bib)$/
l!l&&r!l&&!r
000
MC/DC0%0/3
!defined($s) || $s =~ /\.(tex|bib)$/ and not $s =~ /\.code\.tex$/
not defined $s $s =~ /\.(tex|bib)$/ not $s =~ /\.code\.tex$/
Truth table0%0/5
not(A) or B and not(C)
A= not defined $sB= $s =~ /\.(tex|bib)$/C= not $s =~ /\.code\.tex$/
ABCresult
00X0
1X00
0100
1X11
0111
487 && ($s !~ /\.code\.tex$/)) {
488 0 Info('ignore', $cs, $self->getStomach, "Ignoring redefinition of $cs"); }
489 0 return; }
490 0 assign_internal($self, 'meaning', $cs => $definition, $scope);
491 0 return; }
492  
493 # NOTE: Common usage patterns seem to be to lookup
494 # expandable definitions
495 # register values
496 # conditionals
497 # digestibles
498 # or just variants on testing defined-ness
499 # May be will introduce more clarity (possibly efficiency)
500 # to collect those more uniformly and implement here, or in Package
501  
502 #======================================================================
503  
504 # Generate a stub definition for an undefined control-sequence,
505 # along with appropriate error messge.
506 sub generateErrorStub {
507 0 ▶ my ($self, $caller, $token, $params) = @_;
Subroutine generateErrorStub: not called CC=2 SCAR=17.9
Pod undocumented
508 0 my $cs = $token->getCSName;
509 0 $self->noteStatus(undefined => $cs);
510 # To minimize chatter, go ahead and define it...
511 0 ▶ if ($cs =~ /^\\if(.*)$/) { # Apparently an \ifsomething ???
Branch: 1 branch
BranchTrueFalseTotal
if ($cs =~ /^\\if(.*)$/) { } 0 0 0
512 0 my $name = $1;
513 0 Error('undefined', $token, $caller, "The token " . $token->stringify . " is not defined.",
514 "Defining it now as with \\newif");
515 0 $self->installDefinition(LaTeXML::Core::Definition::Expandable->new(
516 T_CS('\\' . $name . 'true'), undef, '\let' . $cs . '\iftrue'));
517 0 $self->installDefinition(LaTeXML::Core::Definition::Expandable->new(
518 T_CS('\\' . $name . 'false'), undef, '\let' . $cs . '\iffalse'));
519 0 LaTeXML::Package::Let($token, T_CS('\iffalse')); }
520 else {
521 0 Error('undefined', $token, $caller, "The token " . $token->stringify . " is not defined.",
522 "Defining it now as <ltx:ERROR/>");
523 $self->installDefinition(LaTeXML::Core::Definition::Constructor->new($token, $params,
524 0 ▶ sub { $_[0]->makeError('undefined', $cs); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
525 0 sizer => 'X'),
526 'global'); }
527 0 return $token; }
528  
529 #======================================================================
530  
531 sub pushFrame {
532 0 ▶ my ($self, $nobox) = @_;
Subroutine pushFrame: not called CC=1 SCAR=6.9
Pod documented
533 # Easy: just push a new undo hash.
534 0 unshift(@{ $$self{undo} }, {});
535 0 return; }
536  
537 sub popFrame {
538 0 ▶ my ($self) = @_;
Subroutine popFrame: not called CC=4 SCAR=30.0
Pod documented
539 0 ▶ if ($$self{undo}[0]{_FRAME_LOCK_}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'undo'}[0]{'_FRAME_LOCK_'}) { } 0 0 0
540 0 Error('unexpected', '<endgroup>', $self->getStomach,
541 "Attempt to pop last locked stack frame"); }
542 else {
543 0 my $undo = shift(@{ $$self{undo} });
544 0 foreach my $table (keys %$undo) {
545 0 my $undotable = $$undo{$table};
546 0 foreach my $name (keys %$undotable) {
547 # Typically only 1 value to shift off the table, unless scopes have been activated.
548 0 map { shift(@{ $$self{$table}{$name} }) } 1 .. $$undotable{$name}; } } }
549 0 return; }
550  
551 # Determine depth of group nesting created by {,},\bgroup,\egroup,\begingroup,\endgroup
552 # by counting all frames which are not Daemon frames (and thus don't possess _FRAME_LOCK_).
553 # This may give incorrect results for some special environments (e.g. minipage)
554 sub getFrameDepth {
555 0 ▶ my ($self) = @_;
Subroutine getFrameDepth: not called CC=1 SCAR=6.9
Pod undocumented
556 0 return scalar(grep { not defined $$_{_FRAME_LOCK_} } @{ $$self{undo} }) - 1; }
557  
558 #======================================================================
559 # This is primarily about catcodes, but a bit more...
560  
561 sub beginSemiverbatim {
562 0 ▶ my ($self, @extraspecials) = @_;
Subroutine beginSemiverbatim: not called CC=1 SCAR=6.9
Pod undocumented
563 # Is this a good/safe enough shorthand, or should we really be doing beginMode?
564 0 $self->pushFrame;
565 0 $self->assignValue(MODE => 'text');
566 0 $self->assignValue(IN_MATH => 0);
567 0 map { $self->assignCatcode($_ => CC_OTHER, 'local') }
568 0 @{ $self->lookupValue('SPECIALS') }, @extraspecials;
569 0 $self->assignMathcode('\'' => 0x8000, 'local');
570 # try to stay as ASCII as possible
571 0 $self->assignValue(font => $self->lookupValue('font')->merge(encoding => 'ASCII'), 'local');
572 0 return; }
573  
574 sub endSemiverbatim {
575 0 ▶ my ($self) = @_;
Subroutine endSemiverbatim: not called CC=1 SCAR=6.9
Pod undocumented
576 0 $self->popFrame;
577 0 return; }
578  
579 #======================================================================
580  
581 sub pushDaemonFrame {
582 0 ▶ my ($self) = @_;
Subroutine pushDaemonFrame: not called CC=6 SCAR=37.4
Pod undocumented
583 0 my $frame = {};
584 0 unshift(@{ $$self{undo} }, $frame);
585 # Push copys of data for any data that is mutable;
586 # Only the value & stash tables need to be to be checked.
587 # NOTE ??? No...
588 0 foreach my $table (qw(value stash)) {
589 0 ▶ if (my $hash = $$self{$table}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hash = $self->{$table}) 0 0 0
590 0 foreach my $key (keys %$hash) {
591 0 my $value = $$hash{$key}[0];
592 0 my $type = ref $value;
593 0 ▶ if (($type eq 'HASH') || ($type eq 'ARRAY')) { # Only concerned with mutable perl data?
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "HASH" or $type eq "ARRAY") 0 0 0
Condition0%0/3
$type eq "HASH" or $type eq "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "HASH" or $type eq "ARRAY"
$type eq "HASH" $type eq "ARRAY"
Truth table0%0/3
A or B
A= $type eq "HASH"B= $type eq "ARRAY"
ABresult
1X1
011
000
594 # Local assignment
595 0 $$frame{$table}{$key} = 1; # Note new value in this frame.
596 0 unshift(@{ $$hash{$key} }, daemon_copy($value)); } } } } # And push new binding.
597 # Record the contents of LaTeXML::Package::Pool as preloaded
598 0 my $pool_preloaded_hash = { map { $_ => 1 } keys %LaTeXML::Package::Pool:: };
599 0 $self->assignValue('_PRELOADED_POOL_', $pool_preloaded_hash, 'global');
600 # Now mark the top frame as LOCKED!!!
601 0 $$frame{_FRAME_LOCK_} = 1;
602 0 return; }
603  
604 sub daemon_copy {
605 0 ▶ my ($ob) = @_;
Subroutine daemon_copy: not called CC=3 SCAR=24.8
Pod undocumented
606 0 ▶ if (ref $ob eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ob eq 'HASH') { } 0 0 0
elsif (ref $ob eq 'ARRAY') { } 0 0 0
607 0 my %hash = map { ($_ => daemon_copy($$ob{$_})) } keys %$ob;
608 0 return \%hash; }
609 elsif (ref $ob eq 'ARRAY') {
610 0 return [map { daemon_copy($_) } @$ob]; }
611 else {
612 0 return $ob; } }
613  
614 sub popDaemonFrame {
615 0 ▶ my ($self) = @_;
Subroutine popDaemonFrame: not called CC=5 SCAR=34.0
Pod undocumented
616 0 ▶ while (!$$self{undo}[0]{_FRAME_LOCK_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"undo"}[0]{"_FRAME_LOCK_"}) 0 0 0
617 0 $self->popFrame; }
618 0 ▶ if (scalar(@{ $$self{undo} } > 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar(@{$self->{'undo'};} > 1)) { } 0 0 0
619 0 delete $$self{undo}[0]{_FRAME_LOCK_};
620 # Any non-preloaded Pool routines should be wiped away, as we
621 # might want to reuse the Pool namespaces for the next run.
622 0 my $pool_preloaded_hash = $self->lookupValue('_PRELOADED_POOL_');
623 0 $self->assignValue('_PRELOADED_POOL_', undef, 'global');
624 0 foreach my $subname (keys %LaTeXML::Package::Pool::) {
625 0 ▶ unless (exists $$pool_preloaded_hash{$subname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $pool_preloaded_hash->{$subname}) 0 0 0
626 0 undef $LaTeXML::Package::Pool::{$subname};
627 0 delete $LaTeXML::Package::Pool::{$subname};
628 } }
629 # Finally, pop the frame
630 0 $self->popFrame; }
631 else {
632 0 Fatal('unexpected', '<endgroup>', $self->getStomach,
633 "Daemon Attempt to pop last stack frame"); }
634 0 return; }
635  
636 #======================================================================
637 # Set one of the definition prefixes global, etc (only global matters!)
638 sub setPrefix {
639 0 ▶ my ($self, $prefix) = @_;
Subroutine setPrefix: not called CC=1 SCAR=6.9
Pod documented
640 0 $$self{prefixes}{$prefix} = 1;
641 0 return; }
642  
643 sub getPrefix {
644 0 ▶ my ($self, $prefix) = @_;
Subroutine getPrefix: not called CC=1 SCAR=6.9
Pod undocumented
645 0 return $$self{prefixes}{$prefix}; }
646  
647 sub clearPrefixes {
648 0 ▶ my ($self) = @_;
Subroutine clearPrefixes: not called CC=1 SCAR=6.9
Pod documented
649 0 $$self{prefixes} = {};
650 0 return; }
651  
652 #======================================================================
653  
654 sub activateScope {
655 0 ▶ my ($self, $scope) = @_;
Subroutine activateScope: not called CC=4 SCAR=30.0
Pod documented
656 0 ▶ if (!$$self{stash_active}{$scope}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"stash_active"}{$scope}[0]) 0 0 0
657 0 assign_internal($self, 'stash_active', $scope, 1, 'local');
658 0 ▶ if (defined(my $defns = $$self{stash}{$scope}[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $defns = $self->{"stash"}{$scope}[0])) 0 0 0
659 # Now make local assignments for all those in the stash.
660 0 my $frame = $$self{undo}[0];
661 0 foreach my $entry (@$defns) {
662 # Here we ALWAYS push the stashed values into the table
663 # since they may be popped off by deactivateScope
664 0 my ($table, $key, $value) = @$entry;
665 0 $$frame{$table}{$key}++; # Note that this many values must be undone
666 0 unshift(@{ $$self{$table}{$key} }, $value); } } } # And push new binding.
667 0 return; }
668  
669 # Probably, in most cases, the assignments made by activateScope
670 # will be undone by egroup or popping frames.
671 # But they can also be undone explicitly
672 sub deactivateScope {
673 0 ▶ my ($self, $scope) = @_;
Subroutine deactivateScope: not called CC=5 SCAR=34.0
Pod documented
674 0 ▶ if ($$self{stash_active}{$scope}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"stash_active"}{$scope}[0]) 0 0 0
675 0 assign_internal($self, 'stash_active', $scope, 0, 'global');
676 0 ▶ if (defined(my $defns = $$self{stash}{$scope}[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $defns = $self->{"stash"}{$scope}[0])) 0 0 0
677 0 my $frame = $$self{undo}[0];
678 0 foreach my $entry (@$defns) {
679 0 my ($table, $key, $value) = @$entry;
680 0 ▶ if ($$self{$table}{$key}[0] eq $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$table}{$key}[0] eq $value) { } 0 0 0
681 # Here we're popping off the values pushed by activateScope
682 # to (possibly) reveal a local assignment in the same frame, preceding activateScope.
683 0 shift(@{ $$self{$table}{$key} });
684 0 $$frame{$table}{$key}--; }
685 else {
686 Warn('internal', $key, $self->getStomach,
687 "Unassigning wrong value for $key from table $table in deactivateScope",
688 0 "value is $value but stack is " . join(', ', @{ $$self{$table}{$key} })); } } } }
689 0 return; }
690  
691 sub getKnownScopes {
692 0 ▶ my ($self) = @_;
Subroutine getKnownScopes: not called CC=1 SCAR=6.9
Pod undocumented
693 0 my @scopes = sort keys %{ $$self{stash} };
694 0 return @scopes; }
695  
696 sub getActiveScopes {
697 0 ▶ my ($self) = @_;
Subroutine getActiveScopes: not called CC=1 SCAR=6.9
Pod undocumented
698 0 my @scopes = sort keys %{ $$self{stash_active} };
699 0 return @scopes; }
700  
701 #======================================================================
702 # Units.
703  
704 sub convertUnit {
705 0 ▶ my ($self, $unit) = @_;
Subroutine convertUnit: not called CC=5 SCAR=34.0
Pod documented
706 0 $unit = lc($unit);
707 # Put here since it could concievably evolve to depend on the current font.
708 # Eventually try to track font size?
709 0 ▶ if ($unit eq 'em') { return 10.0 * 65536; }
Branch: 3 branches
BranchTrueFalseTotal
if ($unit eq 'em') { } 0 0 0
elsif ($unit eq 'ex') { } 0 0 0
elsif ($unit eq 'mu') { } 0 0 0
710 0 elsif ($unit eq 'ex') { return 4.3 * 65536; }
711 0 elsif ($unit eq 'mu') { return 10.0 * 65536 / 18; }
712 else {
713 0 my $units = $self->lookupValue('UNITS');
714 0 my $sp = $$units{$unit};
715 0 ▶ if (!$sp) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sp) 0 0 0
716 0 Warn('expected', '<unit>', undef, "Illegal unit of measure '$unit', assuming pt.");
717 0 $sp = $$units{'pt'}; }
718 0 return $sp; } }
719  
720 #======================================================================
721  
722 sub noteStatus {
723 0 ▶ my ($self, $type, @data) = @_;
Subroutine noteStatus: not called CC=3 SCAR=24.8
Pod undocumented
724 0 ▶ if ($type eq 'undefined') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'undefined') { } 0 0 0
elsif ($type eq 'missing') { } 0 0 0
725 0 map { $$self{status}{undefined}{$_}++ } @data; }
726 elsif ($type eq 'missing') {
727 0 map { $$self{status}{missing}{$_}++ } @data; }
728 else {
729 0 $$self{status}{$type}++; }
730 0 return; }
731  
732 sub getStatus {
733 0 ▶ my ($self, $type) = @_;
Subroutine getStatus: not called CC=1 SCAR=6.9
Pod undocumented
734 0 return $$self{status}{$type}; }
735  
736 32 our $SUCCESS_MESSAGE = 'No obvious problems';
737  
738 sub getStatusMessage {
739 0 ▶ my ($self) = @_;
Subroutine getStatusMessage: not called CC=30 SCAR=68.4
Pod undocumented
740 0 my $status = $$self{status};
741 0 my @report = ();
742 0 ▶ my $warning_status = $$status{warning} && colorizeString("$$status{warning} warning" . ($$status{warning} > 1 ? 's' : ''), 'warning');
Branch: 1 branch
BranchTrueFalseTotal
$status->{'warning'} > 1 ? : 0 0 0
Condition0%0/3
$status->{'warning'} && colorizeString("$status->{'warning'} warning" . ($status->{'warning'} > 1 ? 's' : ''), 'warning')
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{'warning'} && colorizeString("$status->{'warning'} warning" . ($status->{'warning'} > 1 ? 's' : ''), 'warning')
$status->{'warning'} colorizeString("$status->{'warning'} warning" . ($status->{'warning'} > 1 ? 's' : ''), 'warning')
Truth table0%0/3
A && B
A= $status->{'warning'}B= colorizeString("$status->{'warning'} warning" . ($status->{'warning'} > 1 ? 's' : ''), 'warning')
ABresult
0X0
100
111
743 0 ▶ my $error_status = $$status{error} && colorizeString("$$status{error} error" . ($$status{error} > 1 ? 's' : ''), 'error');
Branch: 1 branch
BranchTrueFalseTotal
$status->{'error'} > 1 ? : 0 0 0
Condition0%0/3
$status->{'error'} && colorizeString("$status->{'error'} error" . ($status->{'error'} > 1 ? 's' : ''), 'error')
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{'error'} && colorizeString("$status->{'error'} error" . ($status->{'error'} > 1 ? 's' : ''), 'error')
$status->{'error'} colorizeString("$status->{'error'} error" . ($status->{'error'} > 1 ? 's' : ''), 'error')
Truth table0%0/3
A && B
A= $status->{'error'}B= colorizeString("$status->{'error'} error" . ($status->{'error'} > 1 ? 's' : ''), 'error')
ABresult
0X0
100
111
744 0 ▶ my $fatal_status = $$status{fatal} && colorizeString("$$status{fatal} fatal error" . ($$status{fatal} > 1 ? 's' : ''), 'fatal');
Branch: 1 branch
BranchTrueFalseTotal
$status->{'fatal'} > 1 ? : 0 0 0
Condition0%0/3
$status->{'fatal'} && colorizeString("$status->{'fatal'} fatal error" . ($status->{'fatal'} > 1 ? 's' : ''), 'fatal')
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{'fatal'} && colorizeString("$status->{'fatal'} fatal error" . ($status->{'fatal'} > 1 ? 's' : ''), 'fatal')
$status->{'fatal'} colorizeString("$status->{'fatal'} fatal error" . ($status->{'fatal'} > 1 ? 's' : ''), 'fatal')
Truth table0%0/3
A && B
A= $status->{'fatal'}B= colorizeString("$status->{'fatal'} fatal error" . ($status->{'fatal'} > 1 ? 's' : ''), 'fatal')
ABresult
0X0
100
111
745 0 ▶ my @undef = ($$status{undefined} ? keys %{ $$status{undefined} } : ());
Branch: 1 branch
BranchTrueFalseTotal
$status->{'undefined'} ? : 0 0 0
746 0 ▶ my $undef_status = @undef && colorizeString(scalar(@undef) . " undefined macro" . (@undef > 1 ? 's' : '')
Branch: 1 branch
BranchTrueFalseTotal
@undef > 1 ? : 0 0 0
Condition0%0/3
@undef && colorizeString(scalar(@undef) . ' undefined macro' . (@undef > 1 ? 's' : '') . '[' . join(', ', @undef) . ']', 'details')
!ll&&!rl&&r
000
MC/DC0%0/2
@undef && colorizeString(scalar(@undef) . ' undefined macro' . (@undef > 1 ? 's' : '') . '[' . join(', ', @undef) . ']', 'details')
@undef colorizeString(scalar(@undef) . ' undefined macro' . (@undef > 1 ? 's' : '') . '[' . join(', ', @undef) . ']', 'details')
Truth table0%0/3
A && B
A= @undefB= colorizeString(scalar(@undef) . ' undefined macro' . (@undef > 1 ? 's' : '') . '[' . join(', ', @undef) . ']', 'details')
ABresult
0X0
100
111
747 . "[" . join(', ', @undef) . "]", 'details');
748 0 ▶ my @miss = ($$status{missing} ? keys %{ $$status{missing} } : ());
Branch: 1 branch
BranchTrueFalseTotal
$status->{'missing'} ? : 0 0 0
749 0 ▶ my $missing_status = @miss && colorizeString(scalar(@miss) . " missing file" . (@miss > 1 ? 's' : '')
Branch: 1 branch
BranchTrueFalseTotal
@miss > 1 ? : 0 0 0
Condition0%0/3
@miss && colorizeString(scalar(@miss) . ' missing file' . (@miss > 1 ? 's' : '') . '[' . join(', ', @miss) . ']', 'details')
!ll&&!rl&&r
000
MC/DC0%0/2
@miss && colorizeString(scalar(@miss) . ' missing file' . (@miss > 1 ? 's' : '') . '[' . join(', ', @miss) . ']', 'details')
@miss colorizeString(scalar(@miss) . ' missing file' . (@miss > 1 ? 's' : '') . '[' . join(', ', @miss) . ']', 'details')
Truth table0%0/3
A && B
A= @missB= colorizeString(scalar(@miss) . ' missing file' . (@miss > 1 ? 's' : '') . '[' . join(', ', @miss) . ']', 'details')
ABresult
0X0
100
111
750 . "[" . join(', ', @miss) . "]", 'details');
751  
752 0 my $success_status = $SUCCESS_MESSAGE;
753 0 ▶ if ($LaTeXML::Common::Error::IS_TERMINAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::IS_TERMINAL) 0 0 0
754 0 ▶ $warning_status = $warning_status && colorizeString($warning_status, 'warning');
Condition0%0/3
$warning_status && colorizeString($warning_status, 'warning')
!ll&&!rl&&r
000
MC/DC0%0/2
$warning_status && colorizeString($warning_status, 'warning')
$warning_status colorizeString($warning_status, 'warning')
Truth table0%0/3
A && B
A= $warning_statusB= colorizeString($warning_status, 'warning')
ABresult
0X0
100
111
755 0 ▶ $error_status = $error_status && colorizeString($error_status, 'error');
Condition0%0/3
$error_status && colorizeString($error_status, 'error')
!ll&&!rl&&r
000
MC/DC0%0/2
$error_status && colorizeString($error_status, 'error')
$error_status colorizeString($error_status, 'error')
Truth table0%0/3
A && B
A= $error_statusB= colorizeString($error_status, 'error')
ABresult
0X0
100
111
756 0 ▶ $fatal_status = $fatal_status && colorizeString($fatal_status, 'fatal');
Condition0%0/3
$fatal_status && colorizeString($fatal_status, 'fatal')
!ll&&!rl&&r
000
MC/DC0%0/2
$fatal_status && colorizeString($fatal_status, 'fatal')
$fatal_status colorizeString($fatal_status, 'fatal')
Truth table0%0/3
A && B
A= $fatal_statusB= colorizeString($fatal_status, 'fatal')
ABresult
0X0
100
111
757 0 ▶ $undef_status = $undef_status && colorizeString($undef_status, 'details');
Condition0%0/3
$undef_status && colorizeString($undef_status, 'details')
!ll&&!rl&&r
000
MC/DC0%0/2
$undef_status && colorizeString($undef_status, 'details')
$undef_status colorizeString($undef_status, 'details')
Truth table0%0/3
A && B
A= $undef_statusB= colorizeString($undef_status, 'details')
ABresult
0X0
100
111
758 0 ▶ $missing_status = $missing_status && colorizeString($missing_status, 'details');
Condition0%0/3
$missing_status && colorizeString($missing_status, 'details')
!ll&&!rl&&r
000
MC/DC0%0/2
$missing_status && colorizeString($missing_status, 'details')
$missing_status colorizeString($missing_status, 'details')
Truth table0%0/3
A && B
A= $missing_statusB= colorizeString($missing_status, 'details')
ABresult
0X0
100
111
759 0 $success_status = colorizeString($success_status, 'success'); }
760  
761 0 ▶ push(@report, $warning_status) if $warning_status;
Branch: 1 branch
BranchTrueFalseTotal
if $warning_status 0 0 0
762 0 ▶ push(@report, $error_status) if $error_status;
Branch: 1 branch
BranchTrueFalseTotal
if $error_status 0 0 0
763 0 ▶ push(@report, $fatal_status) if $fatal_status;
Branch: 1 branch
BranchTrueFalseTotal
if $fatal_status 0 0 0
764 0 ▶ push(@report, $undef_status) if $undef_status;
Branch: 1 branch
BranchTrueFalseTotal
if $undef_status 0 0 0
765 0 ▶ push(@report, $missing_status) if $missing_status;
Branch: 1 branch
BranchTrueFalseTotal
if $missing_status 0 0 0
766  
767 0 ▶ my $message = join('; ', @report) || $success_status;
Condition0%0/3
join('; ', @report) || $success_status
l!l&&r!l&&!r
000
MC/DC0%0/2
join('; ', @report) || $success_status
join('; ', @report) $success_status
Truth table0%0/3
A || B
A= join('; ', @report)B= $success_status
ABresult
1X1
011
000
768 $message .= " (See $LaTeXML::Common::Error::LOG_PATH)"
769 if ($$status{fatal} || $$status{error} || $$status{warning})
770 0 ▶ && $LaTeXML::Common::Error::LOG && !ref $LaTeXML::Common::Error::LOG_PATH;
Branch: 1 branch
BranchTrueFalseTotal
if $status->{"fatal"} || $status->{"error"} || $status->{"warning"} and $LaTeXML::Common::Error::LOG and not ref $LaTeXML::Common::Error::LOG_PATH 0 0 0
Condition0%0/12
$status->{"fatal"} || $status->{"error"} || $status->{"warning"} and $LaTeXML::Common::Error::LOG and not ref $LaTeXML::Common::Error::LOG_PATH
!ll&&!rl&&r
000
$status->{"fatal"} || $status->{"error"} || $status->{"warning"} and $LaTeXML::Common::Error::LOG
!ll&&!rl&&r
000
$status->{"fatal"} or $status->{"error"} or $status->{"warning"}
l!l&&r!l&&!r
000
$status->{"fatal"} or $status->{"error"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$status->{"fatal"} || $status->{"error"} || $status->{"warning"} and $LaTeXML::Common::Error::LOG and not ref $LaTeXML::Common::Error::LOG_PATH
$status->{"fatal"} $status->{"error"} $status->{"warning"} $LaTeXML::Common::Error::LOG not ref $LaTeXML::Common::Error::LOG_PATH
Truth table0%0/10
A or B or C and D and not(E)
A= $status->{"fatal"}B= $status->{"error"}C= $status->{"warning"}D= $LaTeXML::Common::Error::LOGE= not ref $LaTeXML::Common::Error::LOG_PATH
ABCDEresult
000XX0
1XX0X0
01X0X0
0010X0
1XX100
01X100
001100
1XX111
01X111
001111
771 0 return $message; }
772  
773 sub getStatusCode {
774 0 ▶ my ($self) = @_;
Subroutine getStatusCode: not called CC=7 SCAR=40.3
Pod undocumented
775 0 my $status = $$self{status};
776 0 my $code;
777 0 ▶ if ($$status{fatal} && $$status{fatal} > 0) {
Branch: 3 branches
BranchTrueFalseTotal
if ($status->{'fatal'} and $status->{'fatal'} > 0) { } 0 0 0
elsif ($status->{'error'} and $status->{'error'} > 0) { } 0 0 0
elsif ($status->{'warning'} and $status->{'warning'} > 0) { } 0 0 0
Condition0%0/3
$status->{"fatal"} and $status->{"fatal"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{"fatal"} and $status->{"fatal"} > 0
$status->{"fatal"} $status->{"fatal"} > 0
Truth table0%0/3
A and B
A= $status->{"fatal"}B= $status->{"fatal"} > 0
ABresult
0X0
100
111
778 0 $code = 3; }
779 ▶ elsif ($$status{error} && $$status{error} > 0) {
Condition0%0/3
$status->{"error"} and $status->{"error"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{"error"} and $status->{"error"} > 0
$status->{"error"} $status->{"error"} > 0
Truth table0%0/3
A and B
A= $status->{"error"}B= $status->{"error"} > 0
ABresult
0X0
100
111
780 0 $code = 2; }
781 ▶ elsif ($$status{warning} && $$status{warning} > 0) {
Condition0%0/3
$status->{"warning"} and $status->{"warning"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{"warning"} and $status->{"warning"} > 0
$status->{"warning"} $status->{"warning"} > 0
Truth table0%0/3
A and B
A= $status->{"warning"}B= $status->{"warning"} > 0
ABresult
0X0
100
111
782 0 $code = 1; }
783 else {
784 0 $code = 0; }
785 0 return $code; }
786 #======================================================================
787 32 1;
788  
789 __END__
« lib/LaTeXML/Common/Glue.pm ↑ Summary lib/LaTeXML/Common/Error.pm »