Skip to content

Commit

Permalink
Fix emitting comments followed by \r\n
Browse files Browse the repository at this point in the history
Before this patch the `\r` character would be part of the comment and
not the following NewlineWs (which would simply be a `\n`-style
NewlineWs instead of a `\r\n` as one would expect).
  • Loading branch information
fredrikekre committed Jul 7, 2024
1 parent ae7d6ac commit 7bc40f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ function lex_comment(l::Lexer)
valid = true
while true
pc = peekchar(l)
if pc == '\n' || pc == EOF_CHAR
if pc == '\n' || pc == '\r' || pc == EOF_CHAR
return emit(l, valid ? K"Comment" : K"ErrorInvalidUTF8")
end
valid &= isvalid(pc)
Expand Down
2 changes: 2 additions & 0 deletions test/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ end
@test toks("#= #= =#") == ["#= #= =#"=>K"ErrorEofMultiComment"]
@test toks("#=#==#=#") == ["#=#==#=#"=>K"Comment"]
@test toks("#=#==#=") == ["#=#==#="=>K"ErrorEofMultiComment"]
# comment terminated by \r\n
@test toks("#\r\n") == ["#" => K"Comment", "\r\n" => K"NewlineWs"]
end


Expand Down

0 comments on commit 7bc40f3

Please sign in to comment.