lib/LaTeXML/Core/Mouth.pm

filter: Statementstmt 14.2% 39 / 274 Branchbran 0.0% 0 / 158 Conditioncond 0.0% 0 / 145 MC/DCmcdc 0.0% 0 / 76 Subroutinesub 25.0% 11 / 44 Podpod 38.1% 8 / 21 totaltotal 8.0% 58 / 718 CC 131 SCAR 62.9
CC
131
Cov
7%
readToken
1980.0
isEOL
156.0
getNextChar
132.0
CRAP 537.5
« lib/LaTeXML/Post/MakeBibliography.pm ↑ Summary lib/LaTeXML/Common/Glue.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Core::Mouth | #
3 # | Analog of TeX's Mouth: Tokenizes strings & files | #
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::Mouth;
13 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use LaTeXML::Common::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use LaTeXML::Common::Locator;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use LaTeXML::Core::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use LaTeXML::Core::Tokens;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use LaTeXML::Util::Pathname;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use Encode qw(decode);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use base qw(LaTeXML::Common::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 5 our $READLINE_PROGRESS_QUANTUM = 25;
26  
27 # NOTE: that the following methods are (potentially) polymorphic w/Mouty types; Use $self->method
28 # new, initialize, finish, hasMoreInput, getNextLine, getLocator, getSource, stringify
29  
30 # Factory method;
31 # Create an appropriate Mouth
32 # options are
33 # quiet,
34 # atletter,
35 # content
36 0 ▶sub create {
Subroutine create: not called CC=5 SCAR=34.0
Pod documented
37 0 my ($class, $source, %options) = @_;
38 0 ▶ if ($options{content}) { # we've cached the content of this source
Branch: 3 branches
BranchTrueFalseTotal
if ($options{'content'}) { } 0 0 0
elsif ($source =~ s/^literal://) { } 0 0 0
elsif (not defined $source) { } 0 0 0
39 0 my ($dir, $name, $ext) = pathname_split($source);
40 0 $options{source} = $source;
41 0 $options{shortsource} = "$name.$ext";
42 0 return $class->new($options{content}, %options); }
43 elsif ($source =~ s/^literal://) { # we've supplied literal data
44 0 $options{source} = ''; # the source does not have a corresponding file name
45 0 return $class->new($source, %options); }
46 elsif (!defined $source) {
47 0 return $class->new('', %options); }
48 else {
49 0 my $type = pathname_protocol($source);
50 0 my $newclass = "LaTeXML::Core::Mouth::$type";
51 0 ▶ if (!$newclass->can('new')) { # not already defined somewhere?
Branch: 1 branch
BranchTrueFalseTotal
unless ($newclass->can("new")) 0 0 0
52 0 require "LaTeXML/Core/Mouth/$type.pm"; } # Load it!
53 0 return $newclass->new($source, %options); } }
54  
55 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
56 0 my ($class, $string, %options) = @_;
57 0 ▶ $string = q{} unless defined $string;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 0 0 0
58 #$options{source} = "Anonymous String" unless defined $options{source};
59 #$options{shortsource} = "String" unless defined $options{shortsource};
60 my $self = bless { source => $options{source},
61 shortsource => $options{shortsource},
62 fordefinitions => ($options{fordefinitions} ? 1 : 0),
63 at_letter => ($options{at_letter} ? 1 : 0),
64 0 ▶ notes => ($options{notes} ? 1 : 0),
Branch: 3 branches
BranchTrueFalseTotal
$options{'fordefinitions'} ? : 0 0 0
$options{'at_letter'} ? : 0 0 0
$options{'notes'} ? : 0 0 0
65 }, $class;
66 0 openString($self, $string);
67 0 $self->initialize;
68 0 return $self; }
69  
70 0 ▶sub openString {
Subroutine openString: not called CC=6 SCAR=37.4
Pod undocumented
71 0 my ($self, $string) = @_;
72 # if (0){
73 0 ▶ if (defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $string) 0 0 0
74 0 ▶ if (utf8::is_utf8($string)) { } # If already utf7
Branch: 2 branches
BranchTrueFalseTotal
if (utf8::is_utf8($string)) { } 0 0 0
elsif (my $encoding = $LaTeXML::Core::Mouth::STATE->lookupValue('PERL_INPUT_ENCODING')) { } 0 0 0
75 elsif (my $encoding = $STATE->lookupValue('PERL_INPUT_ENCODING')) {
76 # Note that if chars in the input cannot be decoded, they are replaced by \x{FFFD}
77 # I _think_ that for TeX's behaviour we actually should turn such un-decodeable chars in to space(?).
78 0 $string = decode($encoding, $string, Encode::FB_DEFAULT);
79 0 ▶ if ($string =~ s/\x{FFFD}/ /g) { # Just remove the replacement chars, and warn (or Info?)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\x{FFFD}/ /g) 0 0 0
80 0 Info('misdefined', $encoding, $self, "input isn't valid under encoding $encoding"); } } }
81  
82 0 $$self{string} = $string;
83 0 ▶ $$self{buffer} = [(defined $string ? splitLines($string) : ())];
Branch: 1 branch
BranchTrueFalseTotal
defined $string ? : 0 0 0
84 0 return; }
85  
86 0 ▶sub initialize {
Subroutine initialize: not called CC=9 SCAR=45.0
Pod undocumented
87 0 my ($self) = @_;
88 0 $$self{lineno} = 0;
89 0 $$self{colno} = 0;
90 0 $$self{chars} = [];
91 0 $$self{nchars} = 0;
92 0 ▶ if ($$self{notes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"notes"}) 0 0 0
93 0 ▶ my $source = defined($$self{source}) ? ($$self{source} || 'Literal String') : 'Anonymous String';
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'source'} ? : 0 0 0
Condition0%0/2
$self->{"source"} or "Literal String"
l!l
00
MC/DC0%0/1
$self->{"source"} or "Literal String"
$self->{"source"}
Truth table0%0/2
A
A= $self->{"source"}
Aresult
11
00
94 $$self{note_message} = "Processing " . ($$self{fordefinitions} ? "definitions" : "content")
95 0 ▶ . ($$self{fordefinitions} && !$$self{at_letter} ? " w/@ other" : '')
Branch: 2 branches
BranchTrueFalseTotal
$self->{'fordefinitions'} ? : 0 0 0
$self->{'fordefinitions'} && !$self->{'at_letter'} ? : 0 0 0
Condition0%0/3
$self->{"fordefinitions"} and not $self->{"at_letter"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"fordefinitions"} and not $self->{"at_letter"}
$self->{"fordefinitions"} not $self->{"at_letter"}
Truth table0%0/3
A and not(B)
A= $self->{"fordefinitions"}B= not $self->{"at_letter"}
ABresult
0X0
100
111
96 . " " . $source;
97 0 ProgressSpinup($$self{note_message}); }
98 0 ▶ if ($$self{at_letter}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"at_letter"}) 0 0 0
99 0 $$self{saved_at_cc} = $STATE->lookupCatcode('@');
100 0 $STATE->assignCatcode('@' => CC_LETTER); }
101 0 ▶ if ($$self{fordefinitions}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"fordefinitions"}) 0 0 0
102 0 $$self{SAVED_INCLUDE_COMMENTS} = $STATE->lookupValue('INCLUDE_COMMENTS');
103 0 $STATE->assignValue(INCLUDE_COMMENTS => 0); }
104 0 return; }
105  
106 0 ▶sub finish {
Subroutine finish: not called CC=5 SCAR=34.0
Pod undocumented
107 0 my ($self) = @_;
108 0 ▶ return if $$self{finished};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"finished"} 0 0 0
109 0 $$self{finished} = 1;
110 0 $$self{buffer} = [];
111 0 $$self{lineno} = 0;
112 0 $$self{colno} = 0;
113 0 $$self{chars} = [];
114 0 $$self{nchars} = 0;
115  
116 0 ▶ if (exists $$self{saved_at_cc}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"saved_at_cc"}) 0 0 0
117 0 $STATE->assignCatcode('@' => $$self{saved_at_cc}); }
118 0 ▶ if (exists $$self{SAVED_INCLUDE_COMMENTS}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"SAVED_INCLUDE_COMMENTS"}) 0 0 0
119 0 $STATE->assignValue(INCLUDE_COMMENTS => $$self{SAVED_INCLUDE_COMMENTS}); }
120 0 ▶ if ($$self{notes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"notes"}) 0 0 0
121 0 ProgressSpindown($$self{note_message}); }
122 0 return; }
123  
124 # This is (hopefully) a platform independent way of splitting a string
125 # into "lines" ending with CRLF, CR or LF (DOS, Mac or Unix).
126 # Note that TeX considers newlines to be \r, ie CR, ie ^^M
127 0 ▶sub splitLines {
Subroutine splitLines: not called CC=3 SCAR=24.8
Pod undocumented
128 0 my ($string) = @_;
129 0 my @lines = split(/\r\n|\r|\n/s, $string, -1);
130 # split returns an extra empty string if $string ends with an EOL
131 # this must be removed
132 0 ▶ if (@lines && $lines[-1] eq '') { pop(@lines); }
Branch: 1 branch
BranchTrueFalseTotal
if (@lines and $lines[-1] eq "") 0 0 0
Condition0%0/3
@lines and $lines[-1] eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
@lines and $lines[-1] eq ""
@lines $lines[-1] eq ""
Truth table0%0/3
A and B
A= @linesB= $lines[-1] eq ""
ABresult
0X0
100
111
133 0 return @lines; }
134  
135 # This is (hopefully) a correct way to split a line into "chars",
136 # or what is probably more desired is "Grapheme clusters" (even "extended")
137 # These are unicode characters that include any following combining chars, accents & such.
138 # I am thinking that when we deal with unicode this may be the most correct way?
139 # If it's not the way XeTeX does it, perhaps, it must be that ALL combining chars
140 # have to be converted to the proper accent control sequences!
141 0 ▶sub splitChars {
Subroutine splitChars: not called CC=1 SCAR=6.9
Pod undocumented
142 0 my ($line) = @_;
143 0 return [$line =~ m/\X/g]; }
144  
145 0 ▶sub getNextLine {
Subroutine getNextLine: not called CC=2 SCAR=17.9
Pod undocumented
146 0 my ($self) = @_;
147 0 ▶ return unless scalar(@{ $$self{buffer} });
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"buffer"};} 0 0 0
148 0 my $line = shift(@{ $$self{buffer} });
149 0 return $line; }
150  
151 0 ▶sub hasMoreInput {
Subroutine hasMoreInput: not called CC=2 SCAR=17.9
Pod documented
152 0 my ($self) = @_;
153 0 ▶ return !isEOL($self) || scalar(@{ $$self{buffer} }); }
Condition0%0/2
!isEOL($self) || scalar @{$self->{'buffer'};}
l!l
00
MC/DC0%0/1
!isEOL($self) || scalar @{$self->{'buffer'};}
!isEOL($self)
Truth table0%0/2
not(A)
A= !isEOL($self)
Aresult
11
00
154  
155 # Get the next character & it's catcode from the current line of input, even ignored chars
156 # handling TeX's "^^" encoding.
157 # Note that this is the only place where catcode lookup is done (well almost),
158 # and that it is somewhat `inlined'.
159 0 ▶sub getNextChar {
Subroutine getNextChar: not called CC=11 SCAR=48.8
Pod undocumented
160 0 my ($self) = @_;
161 0 ▶ if ($$self{colno} < $$self{nchars}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'colno'} < $self->{'nchars'}) { } 0 0 0
162 0 my $ch = $$self{chars}[$$self{colno}++];
163 0 ▶ my $cc = $$STATE{catcode}{$ch}[0] // CC_OTHER; # $STATE->lookupCatcode($ch); OPEN CODED!
Condition0%0/2
$LaTeXML::Core::Mouth::STATE->{"catcode"}{$ch}[0] // 12
l!l
00
MC/DC0%0/1
$LaTeXML::Core::Mouth::STATE->{"catcode"}{$ch}[0] // 12
$LaTeXML::Core::Mouth::STATE->{"catcode"}{$ch}[0]
Truth table0%0/2
A
A= $LaTeXML::Core::Mouth::STATE->{"catcode"}{$ch}[0]
Aresult
11
00
164 0 ▶ if (($cc == CC_SUPER) # Possible convert ^^x
Branch: 1 branch
BranchTrueFalseTotal
if ($cc == 7 and $self->{"colno"} + 1 < $self->{"nchars"} and $ch eq $self->{"chars"}[$self->{"colno"}]) 0 0 0
Condition0%0/6
$cc == 7 and $self->{"colno"} + 1 < $self->{"nchars"} and $ch eq $self->{"chars"}[$self->{"colno"}]
!ll&&!rl&&r
000
$cc == 7 and $self->{"colno"} + 1 < $self->{"nchars"}
!ll&&!rl&&r
000
MC/DC0%0/3
$cc == 7 and $self->{"colno"} + 1 < $self->{"nchars"} and $ch eq $self->{"chars"}[$self->{"colno"}]
$cc == 7 $self->{"colno"} + 1 < $self->{"nchars"} $ch eq $self->{"chars"}[$self->{"colno"}]
Truth table0%0/4
A and B and C
A= $cc == 7B= $self->{"colno"} + 1 < $self->{"nchars"}C= $ch eq $self->{"chars"}[$self->{"colno"}]
ABCresult
0XX0
10X0
1100
1111
165 && ($$self{colno} + 1 < $$self{nchars}) && ($ch eq $$self{chars}[$$self{colno}])) {
166 0 my ($c1, $c2);
167 0 ▶ if (($$self{colno} + 2 < $$self{nchars}) # ^^ followed by TWO LOWERCASE Hex digits???
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'colno'} + 2 < $self->{'nchars'} and ($c1 = $self->{'chars'}[$self->{'colno'} + 1]) =~ /^[0-9a-f]$/ and ($c2 = $self->{'chars'}[$self->{'colno'} + 2]) =~ /^[0-9a-f]$/) { } 0 0 0
Condition0%0/6
$self->{"colno"} + 2 < $self->{"nchars"} and ($c1 = $self->{"chars"}[$self->{"colno"} + 1]) =~ /^[0-9a-f]$/ and ($c2 = $self->{"chars"}[$self->{"colno"} + 2]) =~ /^[0-9a-f]$/
!ll&&!rl&&r
000
$self->{"colno"} + 2 < $self->{"nchars"} and ($c1 = $self->{"chars"}[$self->{"colno"} + 1]) =~ /^[0-9a-f]$/
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"colno"} + 2 < $self->{"nchars"} and ($c1 = $self->{"chars"}[$self->{"colno"} + 1]) =~ /^[0-9a-f]$/ and ($c2 = $self->{"chars"}[$self->{"colno"} + 2]) =~ /^[0-9a-f]$/
$self->{"colno"} + 2 < $self->{"nchars"} ($c1 = $self->{"chars"}[$self->{"colno"} + 1]) =~ /^[0-9a-f]$/ ($c2 = $self->{"chars"}[$self->{"colno"} + 2]) =~ /^[0-9a-f]$/
Truth table0%0/4
A and B and C
A= $self->{"colno"} + 2 < $self->{"nchars"}B= ($c1 = $self->{"chars"}[$self->{"colno"} + 1]) =~ /^[0-9a-f]$/C= ($c2 = $self->{"chars"}[$self->{"colno"} + 2]) =~ /^[0-9a-f]$/
ABCresult
0XX0
10X0
1100
1111
168 && (($c1 = $$self{chars}[$$self{colno} + 1]) =~ /^[0-9a-f]$/)
169 && (($c2 = $$self{chars}[$$self{colno} + 2]) =~ /^[0-9a-f]$/)) {
170 0 $ch = chr(hex($c1 . $c2));
171 0 splice(@{ $$self{chars} }, $$self{colno} - 1, 4, $ch);
172 0 $$self{nchars} -= 3; }
173 else { # OR ^^ followed by a SINGLE Control char type code???
174 0 my $c = $$self{chars}[$$self{colno} + 1];
175 0 my $cn = ord($c);
176 0 ▶ $ch = chr($cn + ($cn >= 64 ? -64 : 64));
Branch: 1 branch
BranchTrueFalseTotal
$cn >= 64 ? : 0 0 0
177 0 splice(@{ $$self{chars} }, $$self{colno} - 1, 3, $ch);
178 0 $$self{nchars} -= 2; }
179 0 ▶ $cc = $STATE->lookupCatcode($ch) // CC_OTHER; }
Condition0%0/2
$LaTeXML::Core::Mouth::STATE->lookupCatcode($ch) // 12
l!l
00
MC/DC0%0/1
$LaTeXML::Core::Mouth::STATE->lookupCatcode($ch) // 12
$LaTeXML::Core::Mouth::STATE->lookupCatcode($ch)
Truth table0%0/2
A
A= $LaTeXML::Core::Mouth::STATE->lookupCatcode($ch)
Aresult
11
00
180 0 return ($ch, $cc); }
181 else {
182 0 return (undef, undef); } }
183  
184 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
185 0 my ($self) = @_;
186 0 return "Mouth[<string>\@$$self{lineno}x$$self{colno}]"; }
187  
188 #**********************************************************************
189 0 ▶sub getLocator {
Subroutine getLocator: not called CC=4 SCAR=30.0
Pod documented
190 0 my ($self) = @_;
191 0 my ($toLine, $toCol, $fromLine, $fromCol) = ($$self{lineno}, $$self{colno});
192 0 ▶ my $maxCol = ($$self{nchars} ? $$self{nchars} - 1 : 0); #There is always a trailing EOL char
Branch: 1 branch
BranchTrueFalseTotal
$self->{'nchars'} ? : 0 0 0
193 0 ▶ if ((defined $toCol) && ($toCol >= $maxCol)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $toCol and $toCol >= $maxCol) { } 0 0 0
Condition0%0/3
defined $toCol and $toCol >= $maxCol
!ll&&!rl&&r
000
MC/DC0%0/2
defined $toCol and $toCol >= $maxCol
defined $toCol $toCol >= $maxCol
Truth table0%0/3
A and B
A= defined $toColB= $toCol >= $maxCol
ABresult
0X0
100
111
194 0 $fromLine = $toLine;
195 0 $fromCol = 0; }
196 else {
197 0 $fromLine = $toLine;
198 0 $fromCol = $toCol; }
199 0 return LaTeXML::Common::Locator->new($$self{source}, $fromLine, $fromCol, $toLine, $toCol); }
200  
201 0 ▶sub getSource {
Subroutine getSource: not called CC=1 SCAR=6.9
Pod undocumented
202 0 my ($self) = @_;
203 0 return $$self{source}; }
204  
205 #**********************************************************************
206 # See The TeXBook, Chapter 8, The Characters You Type, pp.46--47.
207 #**********************************************************************
208  
209 0 ▶sub handle_escape { # Read control sequence
Subroutine handle_escape: not called CC=8 SCAR=42.8
Pod undocumented
210 0 my ($self) = @_;
211 # NOTE: We're using control sequences WITH the \ prepended!!!
212 0 my ($ch, $cc) = getNextChar($self);
213 # Knuth, p.46 says that Newlines are converted to spaces,
214 # Bit I believe that he does NOT mean within control sequences
215 0 my $cs = "\\" . $ch; # I need this standardized to be able to lookup tokens (A better way???)
216 0 ▶ if ((defined $cc) && ($cc == CC_LETTER)) { # For letter, read more letters for csname.
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cc and $cc == 11) 0 0 0
Condition0%0/3
defined $cc and $cc == 11
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cc and $cc == 11
defined $cc $cc == 11
Truth table0%0/3
A and B
A= defined $ccB= $cc == 11
ABresult
0X0
100
111
217 0 ▶ while ((($ch, $cc) = getNextChar($self)) && (defined $ch) && ($cc == CC_LETTER)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = getNextChar($self) and defined $ch and $cc == 11) 0 0 0
Condition0%0/6
() = getNextChar($self) and defined $ch and $cc == 11
!ll&&!rl&&r
000
() = getNextChar($self) and defined $ch
!ll&&!rl&&r
000
MC/DC0%0/3
() = getNextChar($self) and defined $ch and $cc == 11
() = getNextChar($self) defined $ch $cc == 11
Truth table0%0/4
A and B and C
A= () = getNextChar($self)B= defined $chC= $cc == 11
ABCresult
0XX0
10X0
1100
1111
218 0 $cs .= $ch; }
219 # We WILL skip spaces, but not till next token is read (in case catcode changes!!!!)
220 0 $$self{skipping_spaces} = 1;
221 0 ▶ $$self{colno}-- if (defined $cc) && ($cc != CC_LETTER); }
Branch: 1 branch
BranchTrueFalseTotal
if defined $cc and $cc != 11 0 0 0
Condition0%0/3
defined $cc and $cc != 11
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cc and $cc != 11
defined $cc $cc != 11
Truth table0%0/3
A and B
A= defined $ccB= $cc != 11
ABresult
0X0
100
111
222 0 return T_CS($cs); }
223  
224 0 ▶sub handle_EOL {
Subroutine handle_EOL: not called CC=2 SCAR=17.9
Pod undocumented
225 0 my ($self) = @_;
226 # Note that newines should be converted to space (with " " for content)
227 # but it makes nicer XML with occasional \n. Hopefully, this is harmless?
228 # Note also that \par special handling is done in readToken
229 0 $$self{colno} = $$self{nchars}; # Ignore any remaining characters after EOL
230 0 ▶ return ($STATE->lookupValue('PRESERVE_NEWLINES') ? Token("\n", CC_SPACE) : T_SPACE); }
Branch: 1 branch
BranchTrueFalseTotal
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES') ? : 0 0 0
231  
232 0 ▶sub handle_space {
Subroutine handle_space: not called CC=7 SCAR=40.3
Pod undocumented
233 0 my ($self) = @_;
234 0 my ($ch, $cc);
235 # Skip any following spaces!
236 0 ▶ while ((($ch, $cc) = getNextChar($self)) && (defined $ch) && (($cc == CC_SPACE) || ($cc == CC_EOL))) { }
Branch: 1 branch
BranchTrueFalseTotal
if (() = getNextChar($self) and defined $ch and $cc == 10 || $cc == 5) 0 0 0
Condition0%0/9
() = getNextChar($self) and defined $ch and $cc == 10 || $cc == 5
!ll&&!rl&&r
000
() = getNextChar($self) and defined $ch
!ll&&!rl&&r
000
$cc == 10 or $cc == 5
l!l&&r!l&&!r
000
MC/DC0%0/4
() = getNextChar($self) and defined $ch and $cc == 10 || $cc == 5
() = getNextChar($self) defined $ch $cc == 10 $cc == 5
Truth table0%0/5
A and B and C or D
A= () = getNextChar($self)B= defined $chC= $cc == 10D= $cc == 5
ABCDresult
0XXX0
10XX0
11000
111X1
11011
237 0 ▶ $$self{colno}-- if ($$self{colno} <= $$self{nchars}) && (defined $ch); # backup at nonspace/eol
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"colno"} <= $self->{"nchars"} and defined $ch 0 0 0
Condition0%0/3
$self->{"colno"} <= $self->{"nchars"} and defined $ch
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"colno"} <= $self->{"nchars"} and defined $ch
$self->{"colno"} <= $self->{"nchars"} defined $ch
Truth table0%0/3
A and B
A= $self->{"colno"} <= $self->{"nchars"}B= defined $ch
ABresult
0X0
100
111
238 0 return T_SPACE; }
239  
240 0 ▶sub handle_comment {
Subroutine handle_comment: not called CC=5 SCAR=34.0
Pod undocumented
241 0 my ($self) = @_;
242 0 my $n = $$self{colno};
243 0 $$self{colno} = $$self{nchars};
244 0 my $comment = join('', @{ $$self{chars} }[$n .. $$self{nchars} - 1]);
245 0 $comment =~ s/^\s+//; $comment =~ s/\s+$//;
246 0 ▶ if ($comment && $STATE->lookupValue('INCLUDE_COMMENTS')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($comment and $LaTeXML::Core::Mouth::STATE->lookupValue('INCLUDE_COMMENTS')) { } 0 0 0
elsif (($LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES') || 0) > 1) { } 0 0 0
Condition0%0/3
$comment and $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
!ll&&!rl&&r
000
MC/DC0%0/2
$comment and $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
$comment $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
Truth table0%0/3
A and B
A= $commentB= $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
ABresult
0X0
100
111
247 0 return T_COMMENT($comment); }
248 ▶ elsif (($STATE->lookupValue('PRESERVE_NEWLINES') || 0) > 1) {
Condition0%0/2
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES') || 0
l!l
00
MC/DC0%0/1
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES') || 0
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES')
Truth table0%0/2
A
A= $LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES')
Aresult
11
00
249 0 return T_MARKER('EOL'); } # Required EOL during \read
250 else {
251 0 return; } }
252  
253 # These cache the (presumably small) set of distinct letters, etc
254 # converted to Tokens.
255 # Note that this gets filled during runtime and carries over to through Daemon frames.
256 # However, since the values don't depend on any particular document, bindings, etc,
257 # they should be safe.
258 5 my %LETTER = ();
259 5 my %OTHER = ();
260 5 my %ACTIVE = ();
261  
262 # # Dispatch table for catcodes.
263  
264 # Possibly want to think about caching (common) letters, etc to keep from
265 # creating tokens like crazy... or making them more compact... or ???
266 my @DISPATCH = ( # [CONSTANT]
267 \&handle_escape, # T_ESCAPE
268 0 ▶ sub { ($_[1] eq '{' ? T_BEGIN : Token($_[1], CC_BEGIN)) }, # T_BEGIN
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '{' ? : 0 0 0
269 0 ▶ sub { ($_[1] eq '}' ? T_END : Token($_[1], CC_END)) }, # T_END
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '}' ? : 0 0 0
270 0 ▶ sub { ($_[1] eq '$' ? T_MATH : Token($_[1], CC_MATH)) }, # T_MATH
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '$' ? : 0 0 0
271 0 ▶ sub { ($_[1] eq '&' ? T_ALIGN : Token($_[1], CC_ALIGN)) }, # T_ALIGN
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '&' ? : 0 0 0
272 \&handle_EOL, # T_EOL
273 0 ▶ sub { ($_[1] eq '#' ? T_PARAM : Token($_[1], CC_PARAM)) }, # T_PARAM
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '#' ? : 0 0 0
274 0 ▶ sub { ($_[1] eq '^' ? T_SUPER : Token($_[1], CC_SUPER)) }, # T_SUPER
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '^' ? : 0 0 0
275 0 ▶ sub { ($_[1] eq '_' ? T_SUB : Token($_[1], CC_SUB)) }, # T_SUB
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq '_' ? : 0 0 0
276 0 ▶ sub { undef; }, # T_IGNORE (we'll read next token)
Subroutine __ANON__: not called CC=1 SCAR=6.9
277 \&handle_space, # T_SPACE
278 0 ▶ sub { $LETTER{ $_[1] } || ($LETTER{ $_[1] } = T_LETTER($_[1])); }, # T_LETTER
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$LETTER{$_[1]} or $LETTER{$_[1]} = T_LETTER($_[1]) 0 0 0
279 0 ▶ sub { $OTHER{ $_[1] } || ($OTHER{ $_[1] } = T_OTHER($_[1])); }, # T_OTHER
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$OTHER{$_[1]} or $OTHER{$_[1]} = T_OTHER($_[1]) 0 0 0
280 0 ▶ sub { $ACTIVE{ $_[1] } || ($ACTIVE{ $_[1] } = T_ACTIVE($_[1])); }, # T_ACTIVE
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$ACTIVE{$_[1]} or $ACTIVE{$_[1]} = T_ACTIVE($_[1]) 0 0 0
281 \&handle_comment, # T_COMMENT
282 0 ▶ sub { T_OTHER($_[1]); } # T_INVALID (we could get unicode!)
Subroutine __ANON__: not called CC=1 SCAR=6.9
283 5 );
284  
285 # Read the next token, or undef if exhausted.
286 # Note that this also returns COMMENT tokens containing source comments,
287 # and also locator comments (file, line# info).
288 # LaTeXML::Core::Gullet intercepts them and passes them on at appropriate times.
289 0 ▶sub readToken {
Subroutine readToken: not called CC=44 SCAR=75.9
Pod documented
290 0 my ($self) = @_;
291 0 while (1) { # Iterate till we find a token, or run out. (use return)
292 # ===== Get next line, if we need to.
293 0 ▶ if ($$self{colno} >= $$self{nchars}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"colno"} >= $self->{"nchars"}) 0 0 0
294 0 $$self{lineno}++;
295 0 $$self{colno} = 0;
296 0 my $line = $self->getNextLine;
297 # For \read, we have to return something for EOL, and handle implicit final newline
298 0 ▶ my $read_mode = (($STATE->lookupValue('PRESERVE_NEWLINES') || 0) > 1);
Condition0%0/2
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES') || 0
l!l
00
MC/DC0%0/1
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES') || 0
$LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES')
Truth table0%0/2
A
A= $LaTeXML::Core::Mouth::STATE->lookupValue('PRESERVE_NEWLINES')
Aresult
11
00
299 0 my $eolch = "\r";
300 0 ▶ if (my $eol = $STATE->lookupDefinition(T_CS('\endlinechar'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $eol = $LaTeXML::Core::Mouth::STATE->lookupDefinition(T_CS("\\endlinechar"))) 0 0 0
301 0 $eol = $eol->valueOf()->valueOf;
302 0 ▶ $eolch = (($eol > 0) && ($eol <= 255) ? chr($eol) : undef); }
Branch: 1 branch
BranchTrueFalseTotal
$eol > 0 && $eol <= 255 ? : 0 0 0
Condition0%0/3
$eol > 0 and $eol <= 255
!ll&&!rl&&r
000
MC/DC0%0/2
$eol > 0 and $eol <= 255
$eol > 0 $eol <= 255
Truth table0%0/3
A and B
A= $eol > 0B= $eol <= 255
ABresult
0X0
100
111
303 0 ▶ if (!defined $line) { # Exhausted the input.
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line) 0 0 0
304 0 ▶ my $eolcc = ((defined $eolch) && $STATE->lookupCatcode($eolch)) // CC_OTHER;
Condition0%0/5
defined $eolch && $LaTeXML::Core::Mouth::STATE->lookupCatcode($eolch) // 12
l!l
00
defined $eolch and $LaTeXML::Core::Mouth::STATE->lookupCatcode($eolch)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $eolch && $LaTeXML::Core::Mouth::STATE->lookupCatcode($eolch) // 12
defined $eolch $LaTeXML::Core::Mouth::STATE->lookupCatcode($eolch)
Truth table0%0/3
A and B
A= defined $eolchB= $LaTeXML::Core::Mouth::STATE->lookupCatcode($eolch)
ABresult
111
0X0
100
305 my $eoftoken = $read_mode && (defined $eolch) && !$$self{at_eof} && $$self{source}
306 0 ▶ && ($eolcc == CC_EOL ? T_CS('\par')
Branch: 1 branch
BranchTrueFalseTotal
$eolcc == 5 ? : 0 0 0
Condition0%0/12
$read_mode && defined $eolch && !$self->{'at_eof'} && $self->{'source'} && ($eolcc == 5 ? T_CS('\\par') : Token($eolch, $eolcc))
!ll&&!rl&&r
000
$read_mode and defined $eolch and not $self->{"at_eof"} and $self->{"source"}
!ll&&!rl&&r
000
$read_mode and defined $eolch and not $self->{"at_eof"}
!ll&&!rl&&r
000
$read_mode and defined $eolch
!ll&&!rl&&r
000
MC/DC0%0/5
$read_mode && defined $eolch && !$self->{'at_eof'} && $self->{'source'} && ($eolcc == 5 ? T_CS('\\par') : Token($eolch, $eolcc))
$read_mode defined $eolch not $self->{"at_eof"} $self->{"source"} ($eolcc == 5 ? T_CS('\\par') : Token($eolch, $eolcc))
Truth table0%0/6
A and B and not(C) and D && E
A= $read_modeB= defined $eolchC= not $self->{"at_eof"}D= $self->{"source"}E= ($eolcc == 5 ? T_CS('\\par') : Token($eolch, $eolcc))
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
307 : Token($eolch, $eolcc));
308 0 $$self{at_eof} = 1;
309 0 $$self{chars} = [];
310 0 $$self{nchars} = 0;
311 0 ▶ return $eoftoken if $eoftoken;
Branch: 1 branch
BranchTrueFalseTotal
if $eoftoken 0 0 0
312 0 return; }
313 # Remove trailing spaces from external sources
314 0 ▶ if ($$self{source}) { $line =~ s/ *$//s; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"source"}) 0 0 0
315 # Then append the appropriate \endlinechar, or "\r";
316 0 ▶ $line .= $eolch if defined $eolch;
Branch: 1 branch
BranchTrueFalseTotal
if defined $eolch 0 0 0
317  
318 0 $$self{chars} = splitChars($line);
319 0 $$self{nchars} = scalar(@{ $$self{chars} });
320 # In state N, skip leading spaces & ignored, possibly decoding (trailing space removed above)
321 0 my ($ch, $cc);
322 0 ▶ while ((($ch, $cc) = getNextChar($self)) && (defined $ch)
Branch: 1 branch
BranchTrueFalseTotal
if (() = getNextChar($self) and defined $ch and $cc == 10 || $cc == 9) 0 0 0
Condition0%0/9
() = getNextChar($self) and defined $ch and $cc == 10 || $cc == 9
!ll&&!rl&&r
000
() = getNextChar($self) and defined $ch
!ll&&!rl&&r
000
$cc == 10 or $cc == 9
l!l&&r!l&&!r
000
MC/DC0%0/4
() = getNextChar($self) and defined $ch and $cc == 10 || $cc == 9
() = getNextChar($self) defined $ch $cc == 10 $cc == 9
Truth table0%0/5
A and B and C or D
A= () = getNextChar($self)B= defined $chC= $cc == 10D= $cc == 9
ABCDresult
0XXX0
10XX0
11000
111X1
11011
323 && (($cc == CC_SPACE) || ($cc == CC_IGNORE))) { }
324 0 ▶ if ((defined $ch) && ($cc == CC_EOL)) { # Eolch already? empty line!
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ch and $cc == 5) { } 0 0 0
elsif ($self->{'nchars'} == 0 or $self->{'colno'} > $self->{'nchars'}) { } 0 0 0
Condition0%0/3
defined $ch and $cc == 5
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ch and $cc == 5
defined $ch $cc == 5
Truth table0%0/3
A and B
A= defined $chB= $cc == 5
ABresult
0X0
100
111
325 0 $$self{colno} = $$self{nchars}; # ignore rest of line.
326 0 return T_CS('\par'); }
327 ▶ elsif (($$self{nchars} == 0) || ($$self{colno} > $$self{nchars})) { # Past end of line?
Condition0%0/3
$self->{"nchars"} == 0 or $self->{"colno"} > $self->{"nchars"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"nchars"} == 0 or $self->{"colno"} > $self->{"nchars"}
$self->{"nchars"} == 0 $self->{"colno"} > $self->{"nchars"}
Truth table0%0/3
A or B
A= $self->{"nchars"} == 0B= $self->{"colno"} > $self->{"nchars"}
ABresult
1X1
011
000
328 # If upcoming line is empty, and there is no recognizable EOL, fake one
329 0 ▶ return T_MARKER('EOL') if $read_mode && ((!defined $eolch) || ($eolch ne "\r")); }
Branch: 1 branch
BranchTrueFalseTotal
if $read_mode and !defined($eolch) || $eolch ne "\r" 0 0 0
Condition0%0/6
$read_mode and !defined($eolch) || $eolch ne "\r"
!ll&&!rl&&r
000
not defined $eolch or $eolch ne "\r"
l!l&&r!l&&!r
000
MC/DC0%0/3
$read_mode and !defined($eolch) || $eolch ne "\r"
$read_mode not defined $eolch $eolch ne "\r"
Truth table0%0/4
A and not(B) or C
A= $read_modeB= not defined $eolchC= $eolch ne "\r"
ABCresult
0XX0
1000
11X1
1011
330 else { # Back up over peeked char
331 0 $$self{colno}--; }
332 # Sneak a comment out, every so often.
333 0 ▶ if ((($$self{lineno} % $READLINE_PROGRESS_QUANTUM) == 0) && $STATE->lookupValue('INCLUDE_COMMENTS')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"lineno"} % $LaTeXML::Core::Mouth::READLINE_PROGRESS_QUANTUM == 0 and $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")) 0 0 0
Condition0%0/3
$self->{"lineno"} % $LaTeXML::Core::Mouth::READLINE_PROGRESS_QUANTUM == 0 and $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"lineno"} % $LaTeXML::Core::Mouth::READLINE_PROGRESS_QUANTUM == 0 and $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
$self->{"lineno"} % $LaTeXML::Core::Mouth::READLINE_PROGRESS_QUANTUM == 0 $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
Truth table0%0/3
A and B
A= $self->{"lineno"} % $LaTeXML::Core::Mouth::READLINE_PROGRESS_QUANTUM == 0B= $LaTeXML::Core::Mouth::STATE->lookupValue("INCLUDE_COMMENTS")
ABresult
0X0
100
111
334 0 ▶ return T_COMMENT("**** " . ($$self{shortsource} || 'String') . " Line $$self{lineno} ****"); }
Condition0%0/2
$self->{'shortsource'} || 'String'
l!l
00
MC/DC0%0/1
$self->{'shortsource'} || 'String'
$self->{'shortsource'}
Truth table0%0/2
A
A= $self->{'shortsource'}
Aresult
11
00
335 }
336 0 ▶ if ($$self{skipping_spaces}) { # In state S, skip spaces
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"skipping_spaces"}) 0 0 0
337 0 my ($ch, $cc);
338 0 ▶ while ((($ch, $cc) = getNextChar($self)) && (defined $ch) && ($cc == CC_SPACE)) { }
Branch: 1 branch
BranchTrueFalseTotal
if (() = getNextChar($self) and defined $ch and $cc == 10) 0 0 0
Condition0%0/6
() = getNextChar($self) and defined $ch and $cc == 10
!ll&&!rl&&r
000
() = getNextChar($self) and defined $ch
!ll&&!rl&&r
000
MC/DC0%0/3
() = getNextChar($self) and defined $ch and $cc == 10
() = getNextChar($self) defined $ch $cc == 10
Truth table0%0/4
A and B and C
A= () = getNextChar($self)B= defined $chC= $cc == 10
ABCresult
0XX0
10X0
1100
1111
339 0 ▶ $$self{colno}-- if ($$self{colno} <= $$self{nchars}) && (defined $cc) && ($cc != CC_SPACE);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"colno"} <= $self->{"nchars"} and defined $cc and $cc != 10 0 0 0
Condition0%0/6
$self->{"colno"} <= $self->{"nchars"} and defined $cc and $cc != 10
!ll&&!rl&&r
000
$self->{"colno"} <= $self->{"nchars"} and defined $cc
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"colno"} <= $self->{"nchars"} and defined $cc and $cc != 10
$self->{"colno"} <= $self->{"nchars"} defined $cc $cc != 10
Truth table0%0/4
A and B and C
A= $self->{"colno"} <= $self->{"nchars"}B= defined $ccC= $cc != 10
ABCresult
0XX0
10X0
1100
1111
340 0 ▶ if ((defined $cc) && ($cc == CC_EOL)) { # If we've got an EOL
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cc and $cc == 5) 0 0 0
Condition0%0/3
defined $cc and $cc == 5
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cc and $cc == 5
defined $cc $cc == 5
Truth table0%0/3
A and B
A= defined $ccB= $cc == 5
ABresult
0X0
100
111
341 0 getNextChar($self);
342 0 ▶ $$self{colno}-- if ($$self{colno} < $$self{nchars}); }
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"colno"} < $self->{"nchars"} 0 0 0
343 0 $$self{skipping_spaces} = 0; }
344  
345 # ==== Extract next token from line.
346 0 my ($ch, $cc) = getNextChar($self);
347 0 ▶ my $token = (defined $cc ? $DISPATCH[$cc] : undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $cc ? : 0 0 0
348 0 ▶ $token = &$token($self, $ch) if ref $token eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $token eq "CODE" 0 0 0
349 0 ▶ return $token if defined $token; # Else, repeat till we get something or run out.
Branch: 1 branch
BranchTrueFalseTotal
if defined $token 0 0 0
350 }
351 0 return; }
352  
353 #**********************************************************************
354 # Read all tokens until a token equal to $until (if given), or until exhausted.
355 # Returns an empty Tokens list, if there is no input
356  
357 0 ▶sub readTokens {
Subroutine readTokens: not called CC=4 SCAR=30.0
Pod documented
358 0 my ($self) = @_;
359 0 my @tokens = ();
360 0 ▶ while (defined(my $token = readToken($self))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $token = readToken($self))) 0 0 0
361 0 push(@tokens, $token); }
362 0 ▶ while (@tokens && $tokens[-1]->getCatcode == CC_SPACE) { # Remove trailing space
Branch: 1 branch
BranchTrueFalseTotal
if (@tokens and $tokens[-1]->getCatcode == 10) 0 0 0
Condition0%0/3
@tokens and $tokens[-1]->getCatcode == 10
!ll&&!rl&&r
000
MC/DC0%0/2
@tokens and $tokens[-1]->getCatcode == 10
@tokens $tokens[-1]->getCatcode == 10
Truth table0%0/3
A and B
A= @tokensB= $tokens[-1]->getCatcode == 10
ABresult
0X0
100
111
363 0 pop(@tokens); }
364 0 return Tokens(@tokens); }
365  
366 #**********************************************************************
367 # Read a raw line; there are so many variants of how it should end,
368 # that the Mouth API is left as simple as possible.
369 # Alas: $noread true means NOT to read a new line, but only return
370 # the remainder of the current line, if any. This is useful when combining
371 # with previously peeked tokens from the Gullet.
372 0 ▶sub readRawLine {
Subroutine readRawLine: not called CC=4 SCAR=30.0
Pod documented
373 0 my ($self, $noread) = @_;
374 0 my $line;
375 0 ▶ if ($$self{colno} < $$self{nchars}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'colno'} < $self->{'nchars'}) { } 0 0 0
elsif ($noread) { } 0 0 0
376 0 $line = join('', @{ $$self{chars} }[$$self{colno} .. $$self{nchars} - 1]);
377 # strip the final carriage return, if it has been added back
378 0 $line =~ s/\r$//s;
379 0 $$self{colno} = $$self{nchars}; }
380 elsif ($noread) {
381 0 $line = ''; }
382 else {
383 0 $line = $self->getNextLine;
384 0 ▶ if (!defined $line) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $line) { } 0 0 0
385 0 $$self{at_eof} = 1;
386 0 $$self{chars} = []; $$self{nchars} = 0; $$self{colno} = 0; }
387 else {
388 0 $line =~ s/ *$//s;
389 0 $$self{lineno}++;
390 0 $$self{chars} = splitChars($line);
391 0 $$self{nchars} = scalar(@{ $$self{chars} });
392 0 $$self{colno} = $$self{nchars}; } }
393 0 return $line; }
394  
395 # Be Careful! This is used BOTH for flushing input for \endinput
396 # and for detecting line end for \read
397 0 ▶sub isEOL {
Subroutine isEOL: not called CC=12 SCAR=50.5
Pod undocumented
398 0 my ($self) = @_;
399 0 my $savecolno = $$self{colno};
400 # We have to peek past any ignored tokens & also spaces, if skipping
401 0 ▶ my $skipcc = ($$self{skipping_spaces} ? CC_SPACE : -1);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'skipping_spaces'} ? : 0 0 0
402 0 my ($ch, $cc);
403 0 ▶ while ((($ch, $cc) = getNextChar($self)) && (defined $ch)
Branch: 1 branch
BranchTrueFalseTotal
if (() = getNextChar($self) and defined $ch and $cc == $skipcc || $cc == 9) 0 0 0
Condition0%0/9
() = getNextChar($self) and defined $ch and $cc == $skipcc || $cc == 9
!ll&&!rl&&r
000
() = getNextChar($self) and defined $ch
!ll&&!rl&&r
000
$cc == $skipcc or $cc == 9
l!l&&r!l&&!r
000
MC/DC0%0/4
() = getNextChar($self) and defined $ch and $cc == $skipcc || $cc == 9
() = getNextChar($self) defined $ch $cc == $skipcc $cc == 9
Truth table0%0/5
A and B and C or D
A= () = getNextChar($self)B= defined $chC= $cc == $skipccD= $cc == 9
ABCDresult
0XXX0
10XX0
11000
111X1
11011
404 && (($cc == $skipcc) || ($cc == CC_IGNORE))) { }
405 0 ▶ $$self{colno}-- if ($$self{colno} <= $$self{nchars}) && (defined $cc); # Back-up if too far.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"colno"} <= $self->{"nchars"} and defined $cc 0 0 0
Condition0%0/3
$self->{"colno"} <= $self->{"nchars"} and defined $cc
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"colno"} <= $self->{"nchars"} and defined $cc
$self->{"colno"} <= $self->{"nchars"} defined $cc
Truth table0%0/3
A and B
A= $self->{"colno"} <= $self->{"nchars"}B= defined $cc
ABresult
0X0
100
111
406 # If skipping spaces (really, reading for input (\endinput) ?), jump to end of EOL or comments
407 0 ▶ if ($$self{skipping_spaces} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"skipping_spaces"} and defined $cc and $cc == 5 || $cc == 14) 0 0 0
Condition0%0/9
$self->{"skipping_spaces"} and defined $cc and $cc == 5 || $cc == 14
!ll&&!rl&&r
000
$self->{"skipping_spaces"} and defined $cc
!ll&&!rl&&r
000
$cc == 5 or $cc == 14
l!l&&r!l&&!r
000
MC/DC0%0/4
$self->{"skipping_spaces"} and defined $cc and $cc == 5 || $cc == 14
$self->{"skipping_spaces"} defined $cc $cc == 5 $cc == 14
Truth table0%0/5
A and B and C or D
A= $self->{"skipping_spaces"}B= defined $ccC= $cc == 5D= $cc == 14
ABCDresult
0XXX0
10XX0
11000
111X1
11011
408 (defined $cc) && (($cc == CC_EOL) || ($cc == CC_COMMENT))) { # If we've got EOL|Comment
409 0 $$self{colno} = $$self{nchars}; }
410 0 my $eol = $$self{colno} >= $$self{nchars};
411 0 $$self{colno} = $savecolno;
412 0 return $eol; }
413  
414 #======================================================================
415 5 1;
416  
417 __END__
« lib/LaTeXML/Post/MakeBibliography.pm ↑ Summary lib/LaTeXML/Common/Glue.pm »