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 ...@@ -44,7 +44,7 @@ import Distribution.Verbosity
import System.FilePath ((</>), (<.>)) import System.FilePath ((</>), (<.>))
import System.Directory (copyFile) import System.Directory (copyFile)
import System.IO (IOMode(..), hPutStr, Handle, hClose, openBinaryFile) 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) import Distribution.ParseUtils (parseDependency)
......
...@@ -18,7 +18,6 @@ module Network.Hackage.CabalInstall.Setup ...@@ -18,7 +18,6 @@ module Network.Hackage.CabalInstall.Setup
import Control.Monad (when) import Control.Monad (when)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Text.ParserCombinators.ReadP (readP_to_S)
import Distribution.ParseUtils (parseDependency) import Distribution.ParseUtils (parseDependency)
import Distribution.Compiler (defaultCompilerFlavor, CompilerFlavor(..)) import Distribution.Compiler (defaultCompilerFlavor, CompilerFlavor(..))
import Distribution.Verbosity import Distribution.Verbosity
...@@ -29,6 +28,7 @@ import System.Environment (getProgName) ...@@ -29,6 +28,7 @@ import System.Environment (getProgName)
import Network.Hackage.CabalInstall.Types (TempFlags (..), Action (..) import Network.Hackage.CabalInstall.Types (TempFlags (..), Action (..)
, UnresolvedDependency (..)) , UnresolvedDependency (..))
import Network.Hackage.CabalInstall.Utils (readPToMaybe)
emptyTempFlags :: TempFlags emptyTempFlags :: TempFlags
emptyTempFlags = TempFlags { emptyTempFlags = TempFlags {
...@@ -177,9 +177,9 @@ parsePackageArgs _ args ...@@ -177,9 +177,9 @@ parsePackageArgs _ args
= return (globalArgs,parsePkgArgs pkgs) = return (globalArgs,parsePkgArgs pkgs)
where (globalArgs,pkgs) = break (not.(==)'-'.head) args where (globalArgs,pkgs) = break (not.(==)'-'.head) args
parseDep dep parseDep dep
= case readP_to_S parseDependency dep of = case readPToMaybe parseDependency dep of
[] -> error ("Failed to parse package dependency: " ++ show dep) Nothing -> error ("Failed to parse package dependency: " ++ show dep)
x -> fst (last x) Just x -> x
parsePkgArgs [] = [] parsePkgArgs [] = []
parsePkgArgs (x:xs) parsePkgArgs (x:xs)
= let (args,rest) = break (not.(==) '-'.head) xs = let (args,rest) = break (not.(==) '-'.head) xs
......
module Network.Hackage.CabalInstall.Utils where module Network.Hackage.CabalInstall.Utils where
import Distribution.Compat.ReadP (ReadP, readP_to_S)
import Distribution.Verbosity import Distribution.Verbosity
import Network.Hackage.CabalInstall.Types import Network.Hackage.CabalInstall.Types
import Data.Char (isSpace)
import Data.Maybe (listToMaybe)
isVerbose cfg = configVerbose cfg >= verbose isVerbose cfg = configVerbose cfg >= verbose
\ No newline at end of file
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