Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra guards for empty lines for Mouth::readToken #2215

Merged
merged 2 commits into from
Sep 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/LaTeXML/Core/Mouth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use LaTeXML::Core::Token;
use LaTeXML::Core::Tokens;
use LaTeXML::Util::Pathname;
use Encode qw(decode);
use base qw(LaTeXML::Common::Object);
use base qw(LaTeXML::Common::Object);

our $READLINE_PROGRESS_QUANTUM = 25;

Expand Down Expand Up @@ -214,7 +214,7 @@ sub handle_escape { # Read control sequence
# Bit I believe that he does NOT mean within control sequences
my $cs = "\\" . $ch; # I need this standardized to be able to lookup tokens (A better way???)
if ((defined $cc) && ($cc == CC_LETTER)) { # For letter, read more letters for csname.
while ((($ch, $cc) = getNextChar($self)) && $ch && ($cc == CC_LETTER)) {
while ((($ch, $cc) = getNextChar($self)) && (defined $ch) && ($cc == CC_LETTER)) {
$cs .= $ch; }
# We WILL skip spaces, but not till next token is read (in case catcode changes!!!!)
$$self{skipping_spaces} = 1;
Expand Down Expand Up @@ -321,10 +321,10 @@ sub readToken {
my ($ch, $cc);
while ((($ch, $cc) = getNextChar($self)) && (defined $ch)
&& (($cc == CC_SPACE) || ($cc == CC_IGNORE))) { }
if ($ch && ($cc == CC_EOL)) { # Eolch already? empty line!
$$self{colno} = $$self{nchars}; # ignore rest of line.
if ((defined $ch) && ($cc == CC_EOL)) { # Eolch already? empty line!
$$self{colno} = $$self{nchars}; # ignore rest of line.
return T_CS('\par'); }
elsif ($$self{colno} > $$self{nchars}) { # Past end of line?
elsif (($$self{nchars} == 0) || ($$self{colno} > $$self{nchars})) { # Past end of line?
# If upcoming line is empty, and there is no recognizable EOL, fake one
return T_MARKER('EOL') if $read_mode && ((!defined $eolch) || ($eolch ne "\r")); }
else { # Back up over peeked char
Expand All @@ -347,7 +347,6 @@ sub readToken {
my $token = (defined $cc ? $DISPATCH[$cc] : undef);
$token = &$token($self, $ch) if ref $token eq 'CODE';
return $token if defined $token; # Else, repeat till we get something or run out.

}
return; }

Expand Down
Loading