Skip to content

Commit

Permalink
replace \r\n earlier, alexGetByte is too late
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Jul 17, 2024
1 parent 70fc3af commit 77d0096
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Cryptol/ModuleSystem/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty (NonEmpty(..))
import Data.Function(on)
import Data.Monoid ((<>),Endo(..), Any(..))
import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8')
import System.Directory (doesFileExist, canonicalizePath)
import System.FilePath ( addExtension
Expand Down Expand Up @@ -179,7 +180,7 @@ parseModule path = do
, "Exception: " ++ show exn ]

txt <- case decodeUtf8' bytes of
Right txt -> return txt
Right txt -> return $! (T.replace "\r\n" "\n" txt)
Left e -> badUtf8 path e

let cfg = P.defaultConfig
Expand Down
5 changes: 1 addition & 4 deletions src/Cryptol/Parser/LexerUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,7 @@ alexGetByte i =
do (c,rest) <- T.uncons (input i)
let i' = i { alexPos = move (alexPos i) c, input = rest }
b = byteForChar c
-- treat \r\n as \n
case (b, alexGetByte i') of
(13, skip@(Just (10, _))) -> skip
_ -> pure (b, i')
pure (b, i')

data Layout = Layout | NoLayout

Expand Down

0 comments on commit 77d0096

Please sign in to comment.