Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal On branch : master
http://hackage.haskell.org/trac/ghc/changeset/cbbc616299c92bb1647bf0b0c255006d61f1364f >--------------------------------------------------------------- commit cbbc616299c92bb1647bf0b0c255006d61f1364f Author: bjorn <[email protected]> Date: Sat Oct 6 09:16:15 2007 +0000 Fix dependency parsing from the command line. Before it accepted partial parses, which for example made "cgi=3" parse as "cgi". >--------------------------------------------------------------- .../src/Network/Hackage/CabalInstall/Fetch.hs | 2 +- .../src/Network/Hackage/CabalInstall/Setup.hs | 8 ++++---- .../src/Network/Hackage/CabalInstall/Utils.hs | 8 +++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Fetch.hs b/cabal-install/src/Network/Hackage/CabalInstall/Fetch.hs index 9441931..5bde319 100644 --- a/cabal-install/src/Network/Hackage/CabalInstall/Fetch.hs +++ b/cabal-install/src/Network/Hackage/CabalInstall/Fetch.hs @@ -44,7 +44,7 @@ import Distribution.Verbosity import System.FilePath ((</>), (<.>)) import System.Directory (copyFile) import System.IO (IOMode(..), hPutStr, Handle, hClose, openBinaryFile) -import Text.ParserCombinators.ReadP (readP_to_S) +import Distribution.Compat.ReadP (readP_to_S) import Distribution.ParseUtils (parseDependency) diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs b/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs index 3b056f2..61e9554 100644 --- a/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs +++ b/cabal-install/src/Network/Hackage/CabalInstall/Setup.hs @@ -18,7 +18,6 @@ module Network.Hackage.CabalInstall.Setup import Control.Monad (when) import Data.Maybe (fromMaybe) -import Text.ParserCombinators.ReadP (readP_to_S) import Distribution.ParseUtils (parseDependency) import Distribution.Compiler (defaultCompilerFlavor, CompilerFlavor(..)) import Distribution.Verbosity @@ -29,6 +28,7 @@ import System.Environment (getProgName) import Network.Hackage.CabalInstall.Types (TempFlags (..), Action (..) , UnresolvedDependency (..)) +import Network.Hackage.CabalInstall.Utils (readPToMaybe) emptyTempFlags :: TempFlags emptyTempFlags = TempFlags { @@ -177,9 +177,9 @@ parsePackageArgs _ args = return (globalArgs,parsePkgArgs pkgs) where (globalArgs,pkgs) = break (not.(==)'-'.head) args parseDep dep - = case readP_to_S parseDependency dep of - [] -> error ("Failed to parse package dependency: " ++ show dep) - x -> fst (last x) + = case readPToMaybe parseDependency dep of + Nothing -> error ("Failed to parse package dependency: " ++ show dep) + Just x -> x parsePkgArgs [] = [] parsePkgArgs (x:xs) = let (args,rest) = break (not.(==) '-'.head) xs diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Utils.hs b/cabal-install/src/Network/Hackage/CabalInstall/Utils.hs index af7b773..721f001 100644 --- a/cabal-install/src/Network/Hackage/CabalInstall/Utils.hs +++ b/cabal-install/src/Network/Hackage/CabalInstall/Utils.hs @@ -1,8 +1,14 @@ module Network.Hackage.CabalInstall.Utils where +import Distribution.Compat.ReadP (ReadP, readP_to_S) import Distribution.Verbosity import Network.Hackage.CabalInstall.Types +import Data.Char (isSpace) +import Data.Maybe (listToMaybe) -isVerbose cfg = configVerbose cfg >= verbose \ No newline at end of file +isVerbose cfg = configVerbose cfg >= verbose + +readPToMaybe :: ReadP r a -> String -> Maybe a +readPToMaybe p str = listToMaybe [ r | (r,s) <- readP_to_S p str, all isSpace s ] _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
