Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/b3e30449aa6d6eaa978eb3c7447ca85985d9d251

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

commit b3e30449aa6d6eaa978eb3c7447ca85985d9d251
Author: Ian Lynagh <[email protected]>
Date:   Wed Nov 30 22:49:05 2011 +0000

    Fix parsing of OPTIONS*/LANGUAGE pragmas in haddock mode
    
    When getting options from basicTypes/RdrName.lhs, we were seeing
    text like "-- |\n-- ...\n" in the buffer, and lexer then recognises
    "-- |\n-- ..." as a complete ITdocCommentNext token, with the end of
    the buffer not reached.
    
    Next time round, when we get more input into the buffer, it started
    "\n-- * 'Var.Var': see", so the lexer gave us an ITdocSection token.
    
    However, getOptions' only knew about ITdocCommentNext, and so it
    stopped at that point, and didn't see the pragmas further down the file.
    This caused the build to fail due to -fwarn-tabs not being turned off.
    
    But actually, we don't really want the haddock docs at this point, so
    now we just unset Opt_Haddock in getOptionsFromFile.

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

 compiler/main/HeaderInfo.hs |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/compiler/main/HeaderInfo.hs b/compiler/main/HeaderInfo.hs
index 2b6a14b..9fad73a 100644
--- a/compiler/main/HeaderInfo.hs
+++ b/compiler/main/HeaderInfo.hs
@@ -141,8 +141,17 @@ getOptionsFromFile dflags filename
              (openBinaryFile filename ReadMode)
               (hClose)
               (\handle -> do
-                  opts <- fmap getOptions' $ lazyGetToks dflags filename handle
+                  opts <- fmap getOptions' $ lazyGetToks dflags' filename 
handle
                   seqList opts $ return opts)
+    where -- We don't need to get haddock doc tokens when we're just
+          -- getting the options from pragmas, and lazily lexing them
+          -- correctly is a little tricky: If there is "\n" or "\n-"
+          -- left at the end of a buffer then the haddock doc may
+          -- continue past the end of the buffer, despite the fact that
+          -- we already have an apparently-complete token.
+          -- We therefore just turn Opt_Haddock off when doing the lazy
+          -- lex.
+          dflags' = dopt_unset dflags Opt_Haddock
 
 blockSize :: Int
 -- blockSize = 17 -- for testing :-)
@@ -237,9 +246,6 @@ getOptions' toks
           parseToks (open:xs)
               | ITlanguage_prag <- getToken open
               = parseLanguage xs
-          parseToks (x:xs)
-              | ITdocCommentNext _ <- getToken x
-              = parseToks xs
           parseToks _ = []
           parseLanguage (L loc (ITconid fs):rest)
               = checkExtension (L loc fs) :



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to