[GHC] #14876: Reading source files in text mode so that we get CRLF conversion under Windows?

#14876: Reading source files in text mode so that we get CRLF conversion under Windows? -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- According to https://github.com/sol/interpolate/issues/9 the string passed to a quasi quoter contains CRLF line endings. I have observed the same things for Haddock comments (both in `haddock` and `doctest` when extracted through the GHC API). I haven't looked at any GHC code, but wouldn't the right thing be to read source files in text mode so that we get newline conversion? If we don't want / can't do that for some reason, then wouldn't we still want to handle this somewhere deep down the stack so that not every client has to deal with it separately? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14876 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14876: Reading source files in text mode so that we get CRLF conversion under Windows? -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): GHC uses its `StringBuffer` abstraction, which is essentially just a bytestring, to read source files. `hGetStringBuffer` opens the file in binary mode, leaving UTF-8 decoding to `nextChar` and friends. In principle we could probably do newline conversion there. That being said, I'm a bit weary of changing this in fear of breaking someone relying on the current behavior. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14876#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14876: Reading source files in text mode so that we get CRLF conversion under Windows? -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by SimonHengel): Should we consider to fix this for QuasiQuote only at first? I think passing CRLF to quasi quoters hardly makes sense and can be the source of windows specific bugs. But of course it's still a breaking change. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14876#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14876: Reading source files in text mode so that we get CRLF conversion under Windows? -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by SimonHengel): I haven't tried, but just from looking at the code for {{{quoteFile}}} I think that the current behavior is also inconsistent. {{{quoteFile}}} uses {{{readFile}}} and hence when we use a QuasiQuoter with {{{quoteFile}}} we will get newline conversions, while when we use the QuasiQuoter without {{{quoteFile}}} we do not get newline conversions. https://hackage.haskell.org/package/template- haskell-2.13.0.0/docs/src/Language.Haskell.TH.Quote.html#quoteFile -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14876#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC