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

IO.FS.lines does not remove CR from the line ending in Ubuntu #4573

Closed
Seasawher opened this issue Jun 27, 2024 · 1 comment · Fixed by #4973
Closed

IO.FS.lines does not remove CR from the line ending in Ubuntu #4573

Seasawher opened this issue Jun 27, 2024 · 1 comment · Fixed by #4973
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@Seasawher
Copy link
Contributor

Seasawher commented Jun 27, 2024

Description

IO.FS.lines can treat CRLF file in WIndows only. It does not remove CR in Ubuntu, so it cannot treat CRLF files in Ubuntu (and CI!).

partial def lines (fname : FilePath) : IO (Array String) := do
 let h ← Handle.mk fname Mode.read
 let rec read (lines : Array String) := do
 let line ← h.getLine
 if line.length == 0 then
 pure lines
 else if line.back == '\n' then
 let line := line.dropRight 1
 let line := if System.Platform.isWindows && line.back == '\x0d' then line.dropRight 1 else line
 read <| lines.push line
 else
 pure <| lines.push line
 read #[]

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@Seasawher Seasawher added the bug Something isn't working label Jun 27, 2024
@Kha
Copy link
Member

Kha commented Aug 8, 2024

Please try giving more specific titles and description (you can also use the Zulip chat if you are not sure something is a bug). By "treat", I assume you mean "removes the CR from the line ending"?

@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Aug 9, 2024
@Seasawher Seasawher changed the title possible bug in IO.FS.lines IO.FS.lines does not remove CR break line in Ubuntu Aug 12, 2024
@Seasawher Seasawher changed the title IO.FS.lines does not remove CR break line in Ubuntu IO.FS.lines does not remove CR in Ubuntu Aug 12, 2024
@Seasawher Seasawher changed the title IO.FS.lines does not remove CR in Ubuntu IO.FS.lines does not remove CR from line ending in Ubuntu Aug 12, 2024
@Seasawher Seasawher changed the title IO.FS.lines does not remove CR from line ending in Ubuntu IO.FS.lines does not remove CR from the line ending in Ubuntu Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants