[commit: haddock] master: Fix parsing of single line comments with broken up newlines. (ebd60c5)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:40:25 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/ebd60c5cd0c3642c2d5542c0e126be0a4ec111d9

>---------------------------------------------------------------

commit ebd60c5cd0c3642c2d5542c0e126be0a4ec111d9
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Wed Jun 17 23:43:31 2015 +0200

    Fix parsing of single line comments with broken up newlines.


>---------------------------------------------------------------

ebd60c5cd0c3642c2d5542c0e126be0a4ec111d9
 haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index 70a6927..3ecfc7e 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -47,13 +47,23 @@ chunk [] = []
 chunk str@(c:_)
     | isSpace c = chunk' $ span isSpace str
 chunk str
-    | "--" `isPrefixOf` str = chunk' $ span (not . (== '\n')) str
+    | "--" `isPrefixOf` str = chunk' $ spanToNewline str
     | "{-" `isPrefixOf` str = chunk' $ chunkComment 0 str
     | otherwise = chunk' $ head $ lex str
 
 chunk' :: (String, String) -> [String]
 chunk' (c, rest) = c:(chunk rest)
 
+spanToNewline :: String -> (String, String)
+spanToNewline [] = ([], [])
+spanToNewline ('\\':'\n':str) =
+    let (str', rest) = spanToNewline str
+    in ('\\':'\n':str', rest)
+spanToNewline ('\n':str) = ("\n", str)
+spanToNewline (c:str) =
+    let (str', rest) = spanToNewline str
+    in (c:str', rest)
+
 chunkComment :: Int -> String -> (String, String)
 chunkComment _ [] = ("", "")
 chunkComment depth ('{':'-':str) =



More information about the ghc-commits mailing list