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 59f06bd
Show file tree
Hide file tree
Showing 2 changed files with 5 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
4 changes: 4 additions & 0 deletions test/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,10 @@ end
end
end

@testset "comment terminated by \\r\\n" begin
@test strtok("#\r\n") == ["#", "\r\n", ""]
end

@testset "dotop miscellanea" begin
@test strtok("a .-> b") == ["a", " ", ".-", ">", " ", "b", ""]
@test strtok(".>: b") == [".>:", " ", "b", ""]
Expand Down

0 comments on commit 59f06bd

Please sign in to comment.