Commit cbbc6162 authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Fix dependency parsing from the command line. Before it accepted partial...

Fix dependency parsing from the command line. Before it accepted partial parses, which for example made "cgi=3" parse as "cgi".
parent f19bec1b
......@@ -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)
......
......@@ -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
......
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
readPToMaybe :: ReadP r a -> String -> Maybe a
readPToMaybe p str = listToMaybe [ r | (r,s) <- readP_to_S p str, all isSpace s ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment