From a59185d5034ebb20db88647b245191824a61bcf9 Mon Sep 17 00:00:00 2001 From: Lennart Augustsson Date: Thu, 12 Sep 2024 10:27:59 +0200 Subject: [PATCH] Fix bug --- MicroCabal.cabal | 2 +- src/MicroCabal/Main.hs | 2 ++ src/MicroCabal/Parse.hs | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/MicroCabal.cabal b/MicroCabal.cabal index 462a730..b4e73a4 100644 --- a/MicroCabal.cabal +++ b/MicroCabal.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: MicroCabal -version: 0.2.1.0 +version: 0.2.1.1 synopsis: A partial Cabal replacement license: Apache-2.0 license-file: LICENSE diff --git a/src/MicroCabal/Main.hs b/src/MicroCabal/Main.hs index aff55a7..bdd6d35 100644 --- a/src/MicroCabal/Main.hs +++ b/src/MicroCabal/Main.hs @@ -249,6 +249,7 @@ build env = do sect s@(Section "executable" _ _) | TgtExe `elem` targets env = buildExe env glob s sect s@(Section "library" _ _) | TgtLib `elem` targets env = buildLib env glob s sect _ = return () + message env 2 $ "Normalized Cabal file:\n" ++ show ncbl mapM_ sect $ addMissing sects buildExe :: Env -> Section -> Section -> IO () @@ -309,6 +310,7 @@ install env = do sect s@(Section "executable" _ _) | TgtExe `elem` targets env = installExe env glob s sect s@(Section "library" _ _) | TgtLib `elem` targets env = installLib env glob s sect _ = return () + message env 2 $ "Normalized Cabal file:\n" ++ show ncbl mapM_ sect $ addMissing sects installExe :: Env -> Section -> Section -> IO () diff --git a/src/MicroCabal/Parse.hs b/src/MicroCabal/Parse.hs index 147a739..fb3ecb6 100644 --- a/src/MicroCabal/Parse.hs +++ b/src/MicroCabal/Parse.hs @@ -47,11 +47,6 @@ preLex = loop 0 loop _ ('\r':cs) = loop 0 cs loop n ('\t':cs) = replicate k ' ' ++ loop 0 cs where k = 8 - n `rem` 8 - -- Remove '--MHS'. - -- Hackage does not recognize mhs as a valid compiler yet. - -- Work around this by having mhs stuff in comments that - -- MicroCabal ignores. - loop 0 ('-':'-':'M':'H':'S':cs) = loop 0 cs loop n (c:cs) = c : loop (n+1) cs ------------------------------ @@ -102,9 +97,14 @@ lower :: String -> String lower = map toLower -- Change lines with first non-space being '--' into just a newline +-- Remove '--MHS'. +-- Hackage does not recognize mhs as a valid compiler yet. +-- Work around this by having mhs stuff in comments that +-- MicroCabal ignores. dropCabalComments :: String -> String dropCabalComments = unlines . map cmt . lines where + cmt ('-':'-':'M':'H':'S':cs) = cmt cs cmt s | take 2 (dropWhile (== ' ') s) == "--" = "" | otherwise = s