Skip to content

Commit

Permalink
Avoid compiler warnings about use of partial functions 'head' and 'ta…
Browse files Browse the repository at this point in the history
…il'.
  • Loading branch information
peti committed Mar 26, 2024
1 parent 50e450d commit 9f3333f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Cabal2Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,10 @@ createSpecFile specFile pkgDesc forceBinary runTests flagAssignment copyrightYea
let descr = rstrip isSpace (fromShortText (description pkgDesc))
let descLines = (formatParagraphs . initialCapital . filterSymbols . finalPeriod) $ if badDescription descr then syn' else descr
finalPeriod cs = if last cs == '.' then cs else cs ++ "."
filterSymbols (c:cs) =
if c `notElem` "@\\" then c: filterSymbols cs
else case c of
'@' -> '\'': filterSymbols cs
'\\' -> head cs: filterSymbols (tail cs)
_ -> c: filterSymbols cs
filterSymbols [] = []
filterSymbols ('@':cs) = '\'' : filterSymbols cs
filterSymbols ('\\':c:cs) = c : filterSymbols cs
filterSymbols (c:cs) = c : filterSymbols cs
filterSymbols [] = []
when hasLib $
putDef "pkg_name" name

Expand Down Expand Up @@ -267,7 +264,7 @@ createSpecFile specFile pkgDesc forceBinary runTests flagAssignment copyrightYea
mapM_ (put . (("%{_datadir}/" ++ pkg_name ++ "-%{version}/")++) . avoidSquareBrackets) (sort (dataFiles pkgDesc))

listDirs :: [FilePath] -> [FilePath]
listDirs = nub . concatMap (map joinPath . tail . inits) . nub . map init . filter (\p -> length p > 1) . map splitDirectories
listDirs = nub . concatMap (map joinPath . drop 1 . inits) . nub . map init . filter (\p -> length p > 1) . map splitDirectories

when hasExecPkg $ do
put "%files"
Expand Down

0 comments on commit 9f3333f

Please sign in to comment.