Skip to content
Commits on Source (7)
haskell-filepath-bytestring (1.4.2.1.0-1) unstable; urgency=medium
* Initial release.
-- Sean Whitton <spwhitton@spwhitton.name> Wed, 11 Dec 2019 16:06:57 -0700
filepath-bytestring (1.4.2.1.0) unstable; urgency=medium
* Initial release, based on filepath 1.4.2.1.
-- Joey Hess <id@joeyh.name> Tue, 10 Dec 2019 15:21:14 -0400
Source: haskell-filepath-bytestring
Maintainer: Debian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>
Uploaders: Sean Whitton <spwhitton@spwhitton.name>
Priority: optional
Section: haskell
Build-Depends: debhelper (>= 10),
haskell-devscripts-minimal | haskell-devscripts (>= 0.9),
cdbs,
ghc,
ghc-prof,
libghc-quickcheck2-dev (>= 2.7) <!nocheck>,
libghc-quickcheck2-dev (<< 2.14) <!nocheck>,
Build-Depends-Indep: ghc-doc,
Standards-Version: 4.4.1
Homepage: https://hackage.haskell.org/package/filepath-bytestring
Vcs-Browser: https://salsa.debian.org/haskell-team/DHG_packages/tree/master/p/haskell-filepath-bytestring
Vcs-Git: https://salsa.debian.org/haskell-team/DHG_packages.git
X-Description: library for manipulating RawFilePaths
This package provides functionality for manipulating RawFilePath
values. It can be used as a drop in replacement for the filepath library
to get the benefits of using ByteStrings. It provides three modules:
.
* "System.FilePath.Posix.ByteString" manipulates POSIX/Linux style
RawFilePath values (with / as the path separator).
.
* "System.FilePath.Windows.ByteString" manipulates Windows style
RawFilePath values (with either \ or / as the path separator, and
deals with drives).
.
* "System.FilePath.ByteString" is an alias for the module
appropriate to your platform.
.
All three modules provide the same API, and the same documentation
(calling out differences in the different variants).
Package: libghc-filepath-bytestring-dev
Architecture: any
Depends: ${haskell:Depends},
${misc:Depends},
${shlibs:Depends},
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts},
Provides: ${haskell:Provides},
Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
${haskell:LongDescription}
.
${haskell:Blurb}
Package: libghc-filepath-bytestring-prof
Architecture: any
Depends: ${haskell:Depends},
${misc:Depends},
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts},
Provides: ${haskell:Provides},
Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
${haskell:LongDescription}
.
${haskell:Blurb}
Package: libghc-filepath-bytestring-doc
Architecture: all
Section: doc
Depends: ${haskell:Depends},
${misc:Depends},
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts},
Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
${haskell:LongDescription}
.
${haskell:Blurb}
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: filepath-bytestring
Upstream-Contact: Joey Hess <id@joeyh.name>
Source: https://hackage.haskell.org/package/filepath-bytestring
Files: *
Copyright: (C) 2005-2019 Neil Mitchell
(C) 2019 Joey Hess
License: BSD-3-clause
Files: debian/*
Copyright: (C) 2019 Sean Whitton <spwhitton@spwhitton.name>
License: BSD-3-clause
License: BSD-3-clause
All rights reserved.
.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
.
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
.
* Neither the name of Neil Mitchell nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{-# LANGUAGE RecordWildCards, ViewPatterns #-}
module Generate(main) where
import Control.Exception
import Control.Monad
import Data.Char
import Data.List
import System.Directory
import System.IO
equivtests :: [(Int, String)]
equivtests =
[ (0, "isPathSeparator")
, (0, "isSearchPathSeparator")
, (0, "isExtSeparator")
, (1, "splitExtension")
, (1, "takeExtension")
, (2, "replaceExtension")
, (1, "dropExtension")
, (2, "addExtension")
, (1, "hasExtension")
, (1, "splitExtensions")
, (1, "dropExtensions")
, (1, "takeExtensions")
, (2, "replaceExtensions")
, (2, "isExtensionOf")
, (2, "stripExtension")
, (1, "splitFileName")
, (1, "takeFileName")
, (2, "replaceFileName")
, (1, "dropFileName")
, (1, "takeBaseName")
, (2, "replaceBaseName")
, (1, "takeDirectory")
, (2, "replaceDirectory")
, (2, "combine")
, (1, "splitPath")
, (3, "joinPath")
, (1, "splitDirectories")
, (1, "splitDrive")
, (2, "joinDrive")
, (1, "takeDrive")
, (1, "hasDrive")
, (1, "dropDrive")
, (1, "isDrive")
, (1, "hasTrailingPathSeparator")
, (1, "addTrailingPathSeparator")
, (1, "dropTrailingPathSeparator")
]
main :: IO ()
main = do
src <- readFile "System/FilePath/Internal.hs"
let tests = map renderTest $ concatMap parseTest $ lines src
writeFileBinaryChanged "tests/TestGen.hs" $ unlines $
["-- GENERATED CODE: See ../Generate.hs"
,"{-# LANGUAGE OverloadedStrings #-}"
,"module TestGen(tests) where"
,"import TestUtil"
,"import Data.Char"
,"import qualified System.FilePath.Windows.ByteString as W"
,"import qualified System.FilePath.Posix.ByteString as P"
,"import Data.ByteString (isPrefixOf, isSuffixOf, null, any)"
,"import Prelude hiding (isPrefixOf, isSuffixOf, null, any)"
--,"{-# ANN module \"HLint: ignore\" #-}"
,"tests :: [(String, Property)]"
,"tests ="] ++
[" " ++ c ++ "(" ++ show t1 ++ ", " ++ t2 ++ ")" | (c,(t1,t2)) <- zip ("[":repeat ",") tests] ++
[" ]"]
let mkequivs porw l = [" " ++ c ++ "(" ++ show ("equiv " ++ porw ++ "." ++ t2) ++ ", equiv_" ++ show t1 ++ " Our" ++ porw ++ "." ++ t2 ++ " Their" ++ porw ++ "." ++ t2 ++ ")" | (c,(t1,t2)) <- l]
writeFileBinaryChanged "tests/TestEquiv.hs" $ unlines $
["-- GENERATED CODE: See ../Generate.hs"
,"module TestEquiv(equivtests) where"
,"import TestUtil"
,"import System.FilePath.ByteString (RawFilePath)"
,"import qualified System.FilePath.Windows.ByteString as OurWindows"
,"import qualified System.FilePath.Windows as TheirWindows"
,"import qualified System.FilePath.Posix.ByteString as OurPosix"
,"import qualified System.FilePath.Posix as TheirPosix"
,"equivtests :: [(String, Property)]"
,"equivtests ="] ++
mkequivs "Posix" (zip ("[":repeat ",") equivtests) ++
mkequivs "Windows" (zip (repeat ",") equivtests) ++
[" ]"]
data PW = P | W deriving Show -- Posix or Windows
data Test = Test
{testPlatform :: PW
,testVars :: [(String,String)] -- generator constructor, variable
,testBody :: [String]
}
parseTest :: String -> [Test]
parseTest (stripPrefix "-- > " -> Just x) = platform $ toLexemes x
where
platform ("untested":x) = []
platform ("Windows":":":x) = [valid W x]
platform ("Posix" :":":x) = [valid P x]
platform x = [valid P x, valid W x]
valid p ("Valid":x) = free p a $ drop 1 b
where (a,b) = break (== "=>") x
valid p x = free p [] x
free p val x = Test p [(ctor v, v) | v <- vars] x
where vars = nub $ sort [v | v@[c] <- x, isAlpha c]
ctor v | v < "x" = ""
| v `elem` val = "QFilePathValid" ++ show p
| otherwise = "QFilePath"
parseTest _ = []
toLexemes :: String -> [String]
toLexemes x = case lex x of
[("","")] -> []
[(x,y)] -> x : toLexemes y
y -> error $ "Generate.toLexemes, " ++ show x ++ " -> " ++ show y
fromLexemes :: [String] -> String
fromLexemes = unwords . f
where
f ("`":x:"`":xs) = ("`" ++ x ++ "`") : f xs
f (x:y:xs) | x `elem` ["[","("] || y `elem` [",",")","]"] = f $ (x ++ y) : xs
f (x:xs) = x : f xs
f [] = []
renderTest :: Test -> (String, String)
renderTest Test{..} = (body, code)
where
code = "property $ " ++ if null testVars then body else "\\" ++ unwords vars ++ " -> " ++ convvars body
vars = [if null ctor then v else "(" ++ ctor ++ " " ++ ('v':v) ++ ")" | (ctor,v) <- testVars]
convvars = convvars' $ map snd $ filter (not . null . fst) testVars
convvars' [] b = b
convvars' (v:vs) b = convvars' vs $
"let " ++ v ++ " = toRawFilePath v" ++ v ++ " in " ++ b
body = fromLexemes $ map (qualify testPlatform) testBody
qualify :: PW -> String -> String
qualify pw str
| str `elem` fpops || (all isAlpha str && length str > 1 && str `notElem` prelude) = show pw ++ "." ++ str
| otherwise = str
where
prelude = ["elem","uncurry","snd","fst","not","null","if","then","else"
,"True","False","Just","Nothing","fromJust","concat","isPrefixOf","isSuffixOf","any"
,"fromIntegral","ord","mempty","mconcat"]
fpops = ["</>","<.>","-<.>"]
---------------------------------------------------------------------
-- UTILITIES
writeFileBinary :: FilePath -> String -> IO ()
writeFileBinary file x = withBinaryFile file WriteMode $ \h -> hPutStr h x
readFileBinary' :: FilePath -> IO String
readFileBinary' file = withBinaryFile file ReadMode $ \h -> do
s <- hGetContents h
evaluate $ length s
return s
writeFileBinaryChanged :: FilePath -> String -> IO ()
writeFileBinaryChanged file x = do
b <- doesFileExist file
old <- if b then fmap Just $ readFileBinary' file else return Nothing
when (Just x /= old) $
writeFileBinary file x
#!/usr/bin/make -f
DEB_SETUP_BIN_NAME = debian/hlibrary.setup
DEB_CABAL_PACKAGE = filepath-bytestring
DEB_DEFAULT_COMPILER = ghc
DEB_ENABLE_TESTS = yes
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/hlibrary.mk
version=3
https://hackage.haskell.org/package/filepath-bytestring/distro-monitor .*-([0-9\.]+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))