[commit: packages/Cabal] ghc-head: Be more strict when parsing 'cabal.config'. (f95f793)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:23:20 CEST 2013


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

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=f95f793fd86ed7f8eeae0dbc83d7117a6c4d4e01

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

commit f95f793fd86ed7f8eeae0dbc83d7117a6c4d4e01
Author: Mikhail Glushenkov <the.dead.shall.rise at gmail.com>
Date:   Tue Apr 30 17:56:26 2013 +0200

    Be more strict when parsing 'cabal.config'.
    
    In rare cases (when 'cabal-dev -s .' was used) its 'cabal.config' could conflict
    with our 'cabal.config'.


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

f95f793fd86ed7f8eeae0dbc83d7117a6c4d4e01
 .../Distribution/Client/Sandbox/PackageEnvironment.hs    |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/cabal-install/Distribution/Client/Sandbox/PackageEnvironment.hs b/cabal-install/Distribution/Client/Sandbox/PackageEnvironment.hs
index 4599c52..25fec7a 100644
--- a/cabal-install/Distribution/Client/Sandbox/PackageEnvironment.hs
+++ b/cabal-install/Distribution/Client/Sandbox/PackageEnvironment.hs
@@ -48,7 +48,7 @@ import Distribution.ParseUtils         ( FieldDescr(..), ParseResult(..),
                                          commaListField,
                                          liftField, lineNo, locatedErrorMsg,
                                          parseFilePathQ, readFields,
-                                         showPWarning, simpleField, warning )
+                                         showPWarning, simpleField, syntaxError )
 import Distribution.System             ( Platform )
 import Distribution.Verbosity          ( Verbosity, normal )
 import Control.Monad                   ( foldM, when )
@@ -449,15 +449,15 @@ parsePackageEnvironment initial str = do
     parseSection :: InstallDirs (Flag PathTemplate)
                     -> ParseUtils.Field
                     -> ParseResult (InstallDirs (Flag PathTemplate))
-    parseSection accum (ParseUtils.Section _ "install-dirs" name fs)
+    parseSection accum (ParseUtils.Section line "install-dirs" name fs)
       | name' == "" = do accum' <- parseFields installDirsFields accum fs
                          return accum'
-      | otherwise   = do warning "The install-dirs section should be unnamed"
-                         return accum
+      | otherwise   = syntaxError line $
+                      "The install-dirs section should be unnamed. "
+                      ++ "This file was probably generated by cabal-dev."
       where name' = lowercase name
-    parseSection accum f = do
-      warning $ "Unrecognized stanza on line " ++ show (lineNo f)
-      return accum
+    parseSection _accum f =
+      syntaxError (lineNo f)  "Unrecognized stanza."
 
 -- | Write out the package environment file.
 writePackageEnvironmentFile :: FilePath -> IncludeComments





More information about the ghc-commits mailing list