lib/LaTeXML/Core/State.pm

filter: Statementstmt 4.7% 20 / 418 Branchbran 0.0% 0 / 180 Conditioncond 0.0% 0 / 169 MC/DCmcdc 0.0% 0 / 92 Subroutinesub 7.9% 5 / 63 Podpod 29.8% 17 / 57 totaltotal 4.2% 42 / 979 CC 155 SCAR 52.7
CC
155
Cov
3%
getStatusMessage
930.0
assign_internal
380.0
lookupDigestableDefinition
210.0
CRAP 194.9
« lib/LaTeXML/Core/Token.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 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 33 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 33 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 33 ▶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 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
89 0 my ($class, %options) = @_;
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 0 ▶sub assign_internal {
Subroutine assign_internal: not called CC=19 SCAR=59.4
Pod undocumented
129 0 my ($self, $table, $key, $value, $scope) = @_;
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 0 ▶sub getStomach {
Subroutine getStomach: not called CC=1 SCAR=6.9
Pod documented
171 0 my ($self) = @_;
172 0 return $$self{stomach}; }
173  
174 0 ▶sub getModel {
Subroutine getModel: not called CC=1 SCAR=6.9
Pod documented
175 0 my ($self) = @_;
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 0 ▶sub lookupValue {
Subroutine lookupValue: not called CC=2 SCAR=17.9
Pod documented
184 0 my ($self, $key) = @_;
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 0 ▶sub assignValue {
Subroutine assignValue: not called CC=1 SCAR=6.9
Pod documented
189 0 my ($self, $key, $value, $scope) = @_;
190 0 assign_internal($self, 'value', $key, $value, $scope);
191 0 return; }
192  
193 # manage a (global) list of values
194 0 ▶sub pushValue {
Subroutine pushValue: not called CC=2 SCAR=17.9
Pod documented
195 0 my ($self, $key, @values) = @_;
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 0 ▶sub popValue {
Subroutine popValue: not called CC=2 SCAR=17.9
Pod undocumented
202 0 my ($self, $key) = @_;
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 0 ▶sub unshiftValue {
Subroutine unshiftValue: not called CC=2 SCAR=17.9
Pod undocumented
208 0 my ($self, $key, @values) = @_;
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 0 ▶sub shiftValue {
Subroutine shiftValue: not called CC=2 SCAR=17.9
Pod undocumented
215 0 my ($self, $key) = @_;
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 0 ▶sub lookupMapping {
Subroutine lookupMapping: not called CC=2 SCAR=17.9
Pod undocumented
222 0 my ($self, $map, $key) = @_;
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 0 ▶sub assignMapping {
Subroutine assignMapping: not called CC=3 SCAR=24.8
Pod undocumented
228 0 my ($self, $map, $key, $value) = @_;
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 0 ▶sub lookupMappingKeys {
Subroutine lookupMappingKeys: not called CC=2 SCAR=17.9
Pod undocumented
238 0 my ($self, $map) = @_;
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 0 ▶sub lookupStackedValues {
Subroutine lookupStackedValues: not called CC=2 SCAR=17.9
Pod undocumented
244 0 my ($self, $key) = @_;
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 0 ▶sub isValueBound {
Subroutine isValueBound: not called CC=2 SCAR=17.9
Pod undocumented
252 0 my ($self, $key, $frame) = @_;
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 0 ▶sub valueInFrame {
Subroutine valueInFrame: not called CC=4 SCAR=30.0
Pod undocumented
257 0 my ($self, $key, $frame) = @_;
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 0 ▶sub lookupCatcode {
Subroutine lookupCatcode: not called CC=2 SCAR=17.9
Pod documented
267 0 my ($self, $key) = @_;
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 0 ▶sub assignCatcode {
Subroutine assignCatcode: not called CC=1 SCAR=6.9
Pod documented
272 0 my ($self, $key, $value, $scope) = @_;
273 0 assign_internal($self, 'catcode', $key, $value, $scope);
274 0 return; }
275  
276 # The following rarely used.
277 0 ▶sub lookupMathcode {
Subroutine lookupMathcode: not called CC=2 SCAR=17.9
Pod undocumented
278 0 my ($self, $key) = @_;
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 0 ▶sub assignMathcode {
Subroutine assignMathcode: not called CC=1 SCAR=6.9
Pod undocumented
283 0 my ($self, $key, $value, $scope) = @_;
284 0 assign_internal($self, 'mathcode', $key, $value, $scope);
285 0 return; }
286  
287 0 ▶sub lookupSFcode {
Subroutine lookupSFcode: not called CC=2 SCAR=17.9
Pod undocumented
288 0 my ($self, $key) = @_;
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 0 ▶sub assignSFcode {
Subroutine assignSFcode: not called CC=1 SCAR=6.9
Pod undocumented
293 0 my ($self, $key, $value, $scope) = @_;
294 0 assign_internal($self, 'sfcode', $key, $value, $scope);
295 0 return; }
296  
297 0 ▶sub lookupLCcode {
Subroutine lookupLCcode: not called CC=2 SCAR=17.9
Pod undocumented
298 0 my ($self, $key) = @_;
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 0 ▶sub assignLCcode {
Subroutine assignLCcode: not called CC=1 SCAR=6.9
Pod undocumented
303 0 my ($self, $key, $value, $scope) = @_;
304 0 assign_internal($self, 'lccode', $key, $value, $scope);
305 0 return; }
306  
307 0 ▶sub lookupUCcode {
Subroutine lookupUCcode: not called CC=2 SCAR=17.9
Pod undocumented
308 0 my ($self, $key) = @_;
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 0 ▶sub assignUCcode {
Subroutine assignUCcode: not called CC=1 SCAR=6.9
Pod undocumented
313 0 my ($self, $key, $value, $scope) = @_;
314 0 assign_internal($self, 'uccode', $key, $value, $scope);
315 0 return; }
316  
317 0 ▶sub lookupDelcode {
Subroutine lookupDelcode: not called CC=2 SCAR=17.9
Pod undocumented
318 0 my ($self, $key) = @_;
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 0 ▶sub assignDelcode {
Subroutine assignDelcode: not called CC=1 SCAR=6.9
Pod undocumented
323 0 my ($self, $key, $value, $scope) = @_;
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 33 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 33 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 0 ▶sub lookupMeaning {
Subroutine lookupMeaning: not called CC=5 SCAR=34.0
Pod documented
347 0 my ($self, $token) = @_;
348 0 ▶ if (my $cs = $token
Branch: 1 branch
BranchTrueFalseTotal
if (my $cs = $token && $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] && $token->[0]) { } 0 0 0
Condition0%0/6
$token && $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] && $token->[0]
!ll&&!rl&&r
000
$token and $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]]
!ll&&!rl&&r
000
MC/DC0%0/3
$token && $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] && $token->[0]
$token $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]] $token->[0]
Truth table0%0/4
A and B && C
A= $tokenB= $LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$token->[1]]C= $token->[0]
ABCresult
0XX0
10X0
1100
1111
349 && $CATCODE_ACTIVE_OR_CS[$$token[1]]
350 && $$token[0]) {
351 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
352 0 else { return $token; } }
353  
354 # $meaning should be a definition (for defining active control sequences)
355 # or another token, for \let
356 0 ▶sub assignMeaning {
Subroutine assignMeaning: not called CC=2 SCAR=17.9
Pod documented
357 0 my ($self, $token, $meaning, $scope) = @_;
358 0 ▶ return if $token->equals($meaning); # HACK!!!????
Branch: 1 branch
BranchTrueFalseTotal
if $token->equals($meaning) 0 0 0
359 0 assign_internal($self, 'meaning', $token->getCSName => $meaning, $scope);
360 0 return; }
361  
362 # used for expansion & various queries
363 # Since we're not doing digestion here, we don't need to handle mathactive,
364 # nor cs let to executable tokens
365 # This returns a definition object, or undef
366  
367 # merge of @CATCODE_EXECUTABLE & @CATCODE_PRIMITIVE_NAME
368 33 our @CATCODE_EXECUTABLE_PRIMITIVE_NAME = ( # [CONSTANT]
369 undef, 'Begin', 'End', 'Math',
370 'Align', undef, undef, 'Superscript',
371 'Subscript', undef, undef, undef,
372 undef, undef, undef, undef,
373 undef, undef, undef, undef);
374  
375 0 ▶sub lookupDefinition {
Subroutine lookupDefinition: not called CC=7 SCAR=40.3
Pod undocumented
376 0 my ($self, $token) = @_;
377 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
378 0 my $defn;
379 my $entry;
380 # my $inmath = lookupValue($self, 'IN_MATH');
381 0 my $cc = $$token[1];
382 0 ▶ my $lookupname =
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] ? : 0 0 0
383 ($CATCODE_ACTIVE_OR_CS[$cc]
384 ? $$token[0]
385 : $CATCODE_EXECUTABLE_PRIMITIVE_NAME[$cc]);
386 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
387 && ($entry = $$self{meaning}{$lookupname})
388 && ($defn = $$entry[0])
389 # Can only be a token or definition; we want defns!
390 && ((ref $defn) ne 'LaTeXML::Core::Token')) {
391 0 return $defn; }
392 0 return; }
393  
394 # identical, but for return test; used by skipConditionalBody
395 0 ▶sub lookupConditional {
Subroutine lookupConditional: not called CC=6 SCAR=37.4
Pod undocumented
396 0 my ($self, $token) = @_;
397 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
398 0 my $defn;
399 my $entry;
400 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
401 && ($entry = $$self{meaning}{ $$token[0] })
402 && ($defn = $$entry[0])
403 # Can only be a token or definition; we only want defns that have conditional_type
404 && ((ref $defn) ne 'LaTeXML::Core::Token')) {
405 0 return $$defn{conditional_type}; }
406 0 return; }
407  
408 # Identical but inlined return tests for efficiency; used by readXToken
409 0 ▶sub lookupExpandable {
Subroutine lookupExpandable: not called CC=9 SCAR=45.0
Pod undocumented
410 0 my ($self, $token, $toplevel) = @_;
411 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
412 0 my $defn;
413 my $entry;
414 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->isExpandableF= $toplevelG= not $defn->{"isProtected"}
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11110XX0
11111000
111111X1
11111011
415 && ($entry = $$self{meaning}{ $$token[0] })
416 && ($defn = $$entry[0])
417 # Can only be a token or definition; we want defns!
418 && ((ref $defn) ne 'LaTeXML::Core::Token')
419 && $defn->isExpandable
420 && ($toplevel || !$$defn{isProtected})) { # is this the right logic here? don't expand unless digesting?
421 0 return $defn; }
422 0 return; }
423  
424 # Whether token is affected by \noexpand
425 0 ▶sub isDontExpandable {
Subroutine isDontExpandable: not called CC=7 SCAR=40.3
Pod undocumented
426 0 my ($self, $token) = @_;
427 # Basically: a CS or Active token that is either not defined, or is expandable
428 # (but not \let to a token)
429 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
430 0 my $defn;
431 my $entry;
432 # my $inmath = lookupValue($self, 'IN_MATH');
433 0 my $cc = $$token[1];
434 0 ▶ if ($CATCODE_ACTIVE_OR_CS[$cc]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc]) 0 0 0
435 0 my $lookupname = $$token[0];
436 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
437 && ($entry = $$self{meaning}{$lookupname})
438 && ($defn = $$entry[0])) {
439 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
440 else {
441 0 return 1; } }
442 0 return; }
443  
444 # used for digestion
445 # This recognizes mathactive tokens in math mode
446 # and also looks for cs that have been let to other `executable' tokens
447 # This returns a definition object,
448 # or a "self inserting" token.
449 0 ▶sub lookupDigestableDefinition {
Subroutine lookupDigestableDefinition: not called CC=14 SCAR=53.5
Pod undocumented
450 0 my ($self, $token) = @_;
451 0 ▶ return unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
452 0 my $defn;
453 my $entry;
454 # my $inmath = lookupValue($self, 'IN_MATH');
455 0 my $cc = $$token[1];
456 0 my $name = $$token[0];
457 0 ▶ my $lookupname =
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] || $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] && lookupValue($self, 'IN_MATH') && (lookupMathcode($self, $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 lookupValue($self, "IN_MATH") and (lookupMathcode($self, $name) || 0) == 32768
l!l&&r!l&&!r
000
$LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] and lookupValue($self, "IN_MATH") and (lookupMathcode($self, $name) || 0) == 32768
!ll&&!rl&&r
000
$LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] and lookupValue($self, "IN_MATH")
!ll&&!rl&&r
000
lookupMathcode($self, $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 lookupValue($self, "IN_MATH") and (lookupMathcode($self, $name) || 0) == 32768
$LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc] $LaTeXML::Core::State::CATCODE_LETTER_OR_OTHER[$cc] lookupValue($self, "IN_MATH") lookupMathcode($self, $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= lookupValue($self, "IN_MATH")D= lookupMathcode($self, $name)
ABCDresult
1XXX1
01111
00XX0
010X0
01100
458 (($CATCODE_ACTIVE_OR_CS[$cc]
459 || ($CATCODE_LETTER_OR_OTHER[$cc] && lookupValue($self, 'IN_MATH')
460 && ((lookupMathcode($self, $name) || 0) == 0x8000)))
461 ? $name
462 : $CATCODE_EXECUTABLE_PRIMITIVE_NAME[$cc]);
463 0 ▶ if ($lookupname && ($entry = $$self{meaning}{$lookupname})
Branch: 2 branches
BranchTrueFalseTotal
if ($lookupname and $entry = $self->{'meaning'}{$lookupname} and $defn = $entry->[0]) { } 0 0 0
elsif ($LaTeXML::Core::State::CATCODE_ACTIVE_OR_CS[$cc]) { } 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
464 && ($defn = $$entry[0])) {
465 # If a cs has been let to an executable token, lookup ITS defn.
466 0 ▶ if (((ref $defn) eq 'LaTeXML::Core::Token')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $defn eq "LaTeXML::Core::Token" and $lookupname = $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]] and $entry = $self->{"meaning"}{$lookupname}) 0 0 0
Condition0%0/6
ref $defn eq "LaTeXML::Core::Token" and $lookupname = $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 = $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 = $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]] and $entry = $self->{"meaning"}{$lookupname}
ref $defn eq "LaTeXML::Core::Token" $lookupname = $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 = $LaTeXML::Core::State::CATCODE_EXECUTABLE_PRIMITIVE_NAME[$defn->[1]]C= $entry = $self->{"meaning"}{$lookupname}
ABCresult
0XX0
10X0
1100
1111
467 # If we're digesting an unexpanded, act like \relax
468 && ($lookupname = $CATCODE_EXECUTABLE_PRIMITIVE_NAME[$$defn[1]])
469 && ($entry = $$self{meaning}{$lookupname})) {
470 0 $defn = $$entry[0]; }
471 0 return $defn; }
472 elsif ($CATCODE_ACTIVE_OR_CS[$cc]) {
473 0 return; }
474 0 return $token; }
475  
476 # And a shorthand for installing definitions
477 0 ▶sub installDefinition {
Subroutine installDefinition: not called CC=7 SCAR=40.3
Pod documented
478 0 my ($self, $definition, $scope) = @_;
479 # Locked definitions!!! (or should this test be in assignMeaning?)
480 # Ignore attempts to (re)define $cs from tex sources
481 # my $cs = $definition->getCS->getCSName;
482 0 my $token = $definition->getCS;
483 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
484 0 ▶ if (lookupValue($self, "$cs:locked") && !$LaTeXML::Core::State::UNLOCKED) {
Branch: 1 branch
BranchTrueFalseTotal
if (lookupValue($self, "${cs}:locked") and not $LaTeXML::Core::State::UNLOCKED) 0 0 0
Condition0%0/3
lookupValue($self, "${cs}:locked") and not $LaTeXML::Core::State::UNLOCKED
!ll&&!rl&&r
000
MC/DC0%0/2
lookupValue($self, "${cs}:locked") and not $LaTeXML::Core::State::UNLOCKED
lookupValue($self, "${cs}:locked") not $LaTeXML::Core::State::UNLOCKED
Truth table0%0/3
A and not(B)
A= lookupValue($self, "${cs}:locked")B= not $LaTeXML::Core::State::UNLOCKED
ABresult
0X0
100
111
485 0 my $s = $$self{stomach}->getGullet->getSource;
486 # report if the redefinition seems to come from document source
487 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
488 && ($s !~ /\.code\.tex$/)) {
489 0 Info('ignore', $cs, $$self{stomach}, "Ignoring redefinition of $cs"); }
490 0 return; }
491 0 assign_internal($self, 'meaning', $cs => $definition, $scope);
492 0 return; }
493  
494 # NOTE: Common usage patterns seem to be to lookup
495 # expandable definitions
496 # register values
497 # conditionals
498 # digestibles
499 # or just variants on testing defined-ness
500 # May be will introduce more clarity (possibly efficiency)
501 # to collect those more uniformly and implement here, or in Package
502  
503 #======================================================================
504  
505 # Generate a stub definition for an undefined control-sequence,
506 # along with appropriate error messge.
507 0 ▶sub generateErrorStub {
Subroutine generateErrorStub: not called CC=2 SCAR=17.9
Pod undocumented
508 0 my ($self, $caller, $token, $params) = @_;
509 0 my $cs = $token->getCSName;
510 0 noteStatus($self, undefined => $cs);
511 # To minimize chatter, go ahead and define it...
512 0 ▶ if ($cs =~ /^\\if(.*)$/) { # Apparently an \ifsomething ???
Branch: 1 branch
BranchTrueFalseTotal
if ($cs =~ /^\\if(.*)$/) { } 0 0 0
513 0 my $name = $1;
514 0 Error('undefined', $token, $caller, "The token " . $token->stringify . " is not defined.",
515 "Defining it now as with \\newif");
516 0 installDefinition($self, LaTeXML::Core::Definition::Expandable->new(
517 T_CS('\\' . $name . 'true'), undef, '\let' . $cs . '\iftrue'));
518 0 installDefinition($self, LaTeXML::Core::Definition::Expandable->new(
519 T_CS('\\' . $name . 'false'), undef, '\let' . $cs . '\iffalse'));
520 0 LaTeXML::Package::Let($token, T_CS('\iffalse')); }
521 else {
522 0 Error('undefined', $token, $caller, "The token " . $token->stringify . " is not defined.",
523 "Defining it now as <ltx:ERROR/>");
524 installDefinition($self, LaTeXML::Core::Definition::Constructor->new($token, $params,
525 0 ▶ sub { $_[0]->makeError('undefined', $cs); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
526 0 sizer => 'X'),
527 'global'); }
528 0 return $token; }
529  
530 #======================================================================
531  
532 0 ▶sub pushFrame {
Subroutine pushFrame: not called CC=1 SCAR=6.9
Pod documented
533 0 my ($self, $nobox) = @_;
534 # Easy: just push a new undo hash.
535 0 unshift(@{ $$self{undo} }, {});
536 0 return; }
537  
538 0 ▶sub popFrame {
Subroutine popFrame: not called CC=4 SCAR=30.0
Pod documented
539 0 my ($self) = @_;
540 0 ▶ if ($$self{undo}[0]{_FRAME_LOCK_}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'undo'}[0]{'_FRAME_LOCK_'}) { } 0 0 0
541 Error('unexpected', '<endgroup>', $$self{stomach},
542 0 "Attempt to pop last locked stack frame"); }
543 else {
544 0 my $undo = shift(@{ $$self{undo} });
545 0 foreach my $table (keys %$undo) {
546 0 my $undotable = $$undo{$table};
547 0 foreach my $name (keys %$undotable) {
548 # Typically only 1 value to shift off the table, unless scopes have been activated.
549 0 map { shift(@{ $$self{$table}{$name} }) } 1 .. $$undotable{$name}; } } }
550 0 return; }
551  
552 # Determine depth of group nesting created by {,},\bgroup,\egroup,\begingroup,\endgroup
553 # by counting all frames which are not Daemon frames (and thus don't possess _FRAME_LOCK_).
554 # This may give incorrect results for some special environments (e.g. minipage)
555 0 ▶sub getFrameDepth {
Subroutine getFrameDepth: not called CC=1 SCAR=6.9
Pod undocumented
556 0 my ($self) = @_;
557 0 return scalar(grep { not defined $$_{_FRAME_LOCK_} } @{ $$self{undo} }) - 1; }
558  
559 #======================================================================
560 # This is primarily about catcodes, but a bit more...
561  
562 0 ▶sub beginSemiverbatim {
Subroutine beginSemiverbatim: not called CC=1 SCAR=6.9
Pod undocumented
563 0 my ($self, @extraspecials) = @_;
564 # Is this a good/safe enough shorthand, or should we really be doing beginMode?
565 0 pushFrame($self);
566 0 assignValue($self, MODE => 'text');
567 0 assignValue($self, IN_MATH => 0);
568 0 map { assignCatcode($self, $_ => CC_OTHER, 'local') }
569 0 @{ lookupValue($self, 'SPECIALS') }, @extraspecials;
570 0 assignMathcode($self, '\'' => 0x8000, 'local');
571 # try to stay as ASCII as possible
572 0 assignValue($self, font => lookupValue($self, 'font')->merge(encoding => 'ASCII'), 'local');
573 0 return; }
574  
575 0 ▶sub endSemiverbatim {
Subroutine endSemiverbatim: not called CC=1 SCAR=6.9
Pod undocumented
576 0 my ($self) = @_;
577 0 popFrame($self);
578 0 return; }
579  
580 #======================================================================
581  
582 0 ▶sub pushDaemonFrame {
Subroutine pushDaemonFrame: not called CC=6 SCAR=37.4
Pod undocumented
583 0 my ($self) = @_;
584 0 my $frame = {};
585 0 unshift(@{ $$self{undo} }, $frame);
586 # Push copys of data for any data that is mutable;
587 # Only the value & stash tables need to be to be checked.
588 # NOTE ??? No...
589 0 foreach my $table (qw(value stash)) {
590 0 ▶ if (my $hash = $$self{$table}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hash = $self->{$table}) 0 0 0
591 0 foreach my $key (keys %$hash) {
592 0 my $value = $$hash{$key}[0];
593 0 my $type = ref $value;
594 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
595 # Local assignment
596 0 $$frame{$table}{$key} = 1; # Note new value in this frame.
597 0 unshift(@{ $$hash{$key} }, daemon_copy($value)); } } } } # And push new binding.
598 # Record the contents of LaTeXML::Package::Pool as preloaded
599 0 my $pool_preloaded_hash = { map { $_ => 1 } keys %LaTeXML::Package::Pool:: };
600 0 assignValue($self, '_PRELOADED_POOL_', $pool_preloaded_hash, 'global');
601 # Now mark the top frame as LOCKED!!!
602 0 $$frame{_FRAME_LOCK_} = 1;
603 0 return; }
604  
605 0 ▶sub daemon_copy {
Subroutine daemon_copy: not called CC=3 SCAR=24.8
Pod undocumented
606 0 my ($ob) = @_;
607 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
608 0 my %hash = map { ($_ => daemon_copy($$ob{$_})) } keys %$ob;
609 0 return \%hash; }
610 elsif (ref $ob eq 'ARRAY') {
611 0 return [map { daemon_copy($_) } @$ob]; }
612 else {
613 0 return $ob; } }
614  
615 0 ▶sub popDaemonFrame {
Subroutine popDaemonFrame: not called CC=5 SCAR=34.0
Pod undocumented
616 0 my ($self) = @_;
617 0 ▶ while (!$$self{undo}[0]{_FRAME_LOCK_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"undo"}[0]{"_FRAME_LOCK_"}) 0 0 0
618 0 popFrame($self); }
619 0 ▶ if (scalar(@{ $$self{undo} } > 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar(@{$self->{'undo'};} > 1)) { } 0 0 0
620 0 delete $$self{undo}[0]{_FRAME_LOCK_};
621 # Any non-preloaded Pool routines should be wiped away, as we
622 # might want to reuse the Pool namespaces for the next run.
623 0 my $pool_preloaded_hash = lookupValue($self, '_PRELOADED_POOL_');
624 0 assignValue($self, '_PRELOADED_POOL_', undef, 'global');
625 0 foreach my $subname (keys %LaTeXML::Package::Pool::) {
626 0 ▶ unless (exists $$pool_preloaded_hash{$subname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $pool_preloaded_hash->{$subname}) 0 0 0
627 0 undef $LaTeXML::Package::Pool::{$subname};
628 0 delete $LaTeXML::Package::Pool::{$subname};
629 } }
630 # Finally, pop the frame
631 0 popFrame($self); }
632 else {
633 Fatal('unexpected', '<endgroup>', $$self{stomach},
634 0 "Daemon Attempt to pop last stack frame"); }
635 0 return; }
636  
637 #======================================================================
638 # Set one of the definition prefixes global, etc (only global matters!)
639 0 ▶sub setPrefix {
Subroutine setPrefix: not called CC=1 SCAR=6.9
Pod documented
640 0 my ($self, $prefix) = @_;
641 0 $$self{prefixes}{$prefix} = 1;
642 0 return; }
643  
644 0 ▶sub getPrefix {
Subroutine getPrefix: not called CC=1 SCAR=6.9
Pod undocumented
645 0 my ($self, $prefix) = @_;
646 0 return $$self{prefixes}{$prefix}; }
647  
648 0 ▶sub clearPrefixes {
Subroutine clearPrefixes: not called CC=1 SCAR=6.9
Pod documented
649 0 my ($self) = @_;
650 0 $$self{prefixes} = {};
651 0 return; }
652  
653 #======================================================================
654  
655 0 ▶sub activateScope {
Subroutine activateScope: not called CC=4 SCAR=30.0
Pod documented
656 0 my ($self, $scope) = @_;
657 0 ▶ if (!$$self{stash_active}{$scope}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"stash_active"}{$scope}[0]) 0 0 0
658 0 assign_internal($self, 'stash_active', $scope, 1, 'local');
659 0 ▶ if (defined(my $defns = $$self{stash}{$scope}[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $defns = $self->{"stash"}{$scope}[0])) 0 0 0
660 # Now make local assignments for all those in the stash.
661 0 my $frame = $$self{undo}[0];
662 0 foreach my $entry (@$defns) {
663 # Here we ALWAYS push the stashed values into the table
664 # since they may be popped off by deactivateScope
665 0 my ($table, $key, $value) = @$entry;
666 0 $$frame{$table}{$key}++; # Note that this many values must be undone
667 0 unshift(@{ $$self{$table}{$key} }, $value); } } } # And push new binding.
668 0 return; }
669  
670 # Probably, in most cases, the assignments made by activateScope
671 # will be undone by egroup or popping frames.
672 # But they can also be undone explicitly
673 0 ▶sub deactivateScope {
Subroutine deactivateScope: not called CC=5 SCAR=34.0
Pod documented
674 0 my ($self, $scope) = @_;
675 0 ▶ if ($$self{stash_active}{$scope}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"stash_active"}{$scope}[0]) 0 0 0
676 0 assign_internal($self, 'stash_active', $scope, 0, 'global');
677 0 ▶ if (defined(my $defns = $$self{stash}{$scope}[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $defns = $self->{"stash"}{$scope}[0])) 0 0 0
678 0 my $frame = $$self{undo}[0];
679 0 foreach my $entry (@$defns) {
680 0 my ($table, $key, $value) = @$entry;
681 0 ▶ if ($$self{$table}{$key}[0] eq $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$table}{$key}[0] eq $value) { } 0 0 0
682 # Here we're popping off the values pushed by activateScope
683 # to (possibly) reveal a local assignment in the same frame, preceding activateScope.
684 0 shift(@{ $$self{$table}{$key} });
685 0 $$frame{$table}{$key}--; }
686 else {
687 Warn('internal', $key, $$self{stomach},
688 "Unassigning wrong value for $key from table $table in deactivateScope",
689 0 "value is $value but stack is " . join(', ', @{ $$self{$table}{$key} })); } } } }
690 0 return; }
691  
692 0 ▶sub getKnownScopes {
Subroutine getKnownScopes: not called CC=1 SCAR=6.9
Pod undocumented
693 0 my ($self) = @_;
694 0 my @scopes = sort keys %{ $$self{stash} };
695 0 return @scopes; }
696  
697 0 ▶sub getActiveScopes {
Subroutine getActiveScopes: not called CC=1 SCAR=6.9
Pod undocumented
698 0 my ($self) = @_;
699 0 my @scopes = sort keys %{ $$self{stash_active} };
700 0 return @scopes; }
701  
702 #======================================================================
703 # Units.
704  
705 0 ▶sub convertUnit {
Subroutine convertUnit: not called CC=5 SCAR=34.0
Pod documented
706 0 my ($self, $unit) = @_;
707 0 $unit = lc($unit);
708 # Put here since it could concievably evolve to depend on the current font.
709 # Eventually try to track font size?
710 0 ▶ if ($unit eq 'em') { return lookupValue($self, 'font')->getEMWidth; }
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
711 0 elsif ($unit eq 'ex') { return lookupValue($self, 'font')->getEXHeight; }
712 0 elsif ($unit eq 'mu') { return lookupValue($self, 'font')->getMUWidth; }
713 else {
714 0 my $units = lookupValue($self, 'UNITS');
715 0 my $sp = $$units{$unit};
716 0 ▶ if (!$sp) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sp) 0 0 0
717 0 Warn('expected', '<unit>', undef, "Illegal unit of measure '$unit', assuming pt.");
718 0 $sp = $$units{'pt'}; }
719 0 return $sp; } }
720  
721 #======================================================================
722  
723 0 ▶sub noteStatus {
Subroutine noteStatus: not called CC=3 SCAR=24.8
Pod undocumented
724 0 my ($self, $type, @data) = @_;
725 0 ▶ if ($type eq 'undefined') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'undefined') { } 0 0 0
elsif ($type eq 'missing') { } 0 0 0
726 0 map { $$self{status}{undefined}{$_}++ } @data; }
727 elsif ($type eq 'missing') {
728 0 map { $$self{status}{missing}{$_}++ } @data; }
729 else {
730 0 $$self{status}{$type}++; }
731 0 return; }
732  
733 0 ▶sub getStatus {
Subroutine getStatus: not called CC=1 SCAR=6.9
Pod undocumented
734 0 my ($self, $type) = @_;
735 0 return $$self{status}{$type}; }
736  
737 33 our $SUCCESS_MESSAGE = 'No obvious problems';
738  
739 0 ▶sub getStatusMessage {
Subroutine getStatusMessage: not called CC=30 SCAR=68.4
Pod undocumented
740 0 my ($self) = @_;
741 0 my $status = $$self{status};
742 0 my @report = ();
743 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
744 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
745 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
746 0 ▶ my @undef = ($$status{undefined} ? keys %{ $$status{undefined} } : ());
Branch: 1 branch
BranchTrueFalseTotal
$status->{'undefined'} ? : 0 0 0
747 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
748 . "[" . join(', ', @undef) . "]", 'details');
749 0 ▶ my @miss = ($$status{missing} ? keys %{ $$status{missing} } : ());
Branch: 1 branch
BranchTrueFalseTotal
$status->{'missing'} ? : 0 0 0
750 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
751 . "[" . join(', ', @miss) . "]", 'details');
752  
753 0 my $success_status = $SUCCESS_MESSAGE;
754 0 ▶ if ($LaTeXML::Common::Error::IS_TERMINAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::Common::Error::IS_TERMINAL) 0 0 0
755 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
756 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
757 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
758 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
759 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
760 0 $success_status = colorizeString($success_status, 'success'); }
761  
762 0 ▶ push(@report, $warning_status) if $warning_status;
Branch: 1 branch
BranchTrueFalseTotal
if $warning_status 0 0 0
763 0 ▶ push(@report, $error_status) if $error_status;
Branch: 1 branch
BranchTrueFalseTotal
if $error_status 0 0 0
764 0 ▶ push(@report, $fatal_status) if $fatal_status;
Branch: 1 branch
BranchTrueFalseTotal
if $fatal_status 0 0 0
765 0 ▶ push(@report, $undef_status) if $undef_status;
Branch: 1 branch
BranchTrueFalseTotal
if $undef_status 0 0 0
766 0 ▶ push(@report, $missing_status) if $missing_status;
Branch: 1 branch
BranchTrueFalseTotal
if $missing_status 0 0 0
767  
768 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
769 $message .= " (See $LaTeXML::Common::Error::LOG_PATH)"
770 if ($$status{fatal} || $$status{error} || $$status{warning})
771 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
772 0 return $message; }
773  
774 0 ▶sub getStatusCode {
Subroutine getStatusCode: not called CC=7 SCAR=40.3
Pod undocumented
775 0 my ($self) = @_;
776 0 my $status = $$self{status};
777 0 my $code;
778 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
779 0 $code = 3; }
780 ▶ 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
781 0 $code = 2; }
782 ▶ 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
783 0 $code = 1; }
784 else {
785 0 $code = 0; }
786 0 return $code; }
787 #======================================================================
788 33 1;
789  
790 __END__
« lib/LaTeXML/Core/Token.pm ↑ Summary lib/LaTeXML/Common/Error.pm »