[darcs-users] darcs patch: Make utf8-string mandatory. (and 1 more)
Eric Kow
kowey at darcs.net
Wed Jul 22 09:38:24 UTC 2009
Hi Ganesh,
On Wed, Jul 22, 2009 at 11:24:35 +0200, Petr Rockai wrote:
> Hi,
>
> while we are in a cleanup mode, let's also get rid of the bad ugly custom zlib
> binding...
Any comments? I think you advised a more deliberate approach with the
zlib stuff at the hackathon, which my natural inclination is to agree
with.
I'm personally happy with leaving the old zlib stuff in there until
2.5 (not built by default). On the other hand, I recognise that my
style of dragging things out in the name of conservatism/carefulness
leads to a lot of undue pain. If you neither of you can convince the
other, I think I'm willing to try it Petr's way.
> Tue Jul 21 21:44:33 CEST 2009 Eric Kow <kowey at darcs.net>
> * Make utf8-string mandatory.
>
> Wed Jul 22 11:13:25 CEST 2009 Petr Rockai <me at mornfall.net>
> * Require haskell zlib, dropping the legacy internal zlib binding.
Require haskell zlib, dropping the legacy internal zlib binding.
----------------------------------------------------------------
> Petr Rockai <me at mornfall.net>**20090722091325
> Ignore-this: 348c1fd005fe19900e4a9706567b4ee0
> ] hunk ./darcs.cabal 86
> flag http
> description: Use the pure Haskell HTTP package for HTTP support.
>
> -flag zlib
> - description: Use the external zlib binding package.
> - default: True
> -
> flag terminfo
> description: Use the terminfo package for enhanced console support.
>
> hunk ./darcs.cabal 118
> if !flag(type-witnesses)
> buildable: False
>
> - if !flag(zlib)
> - extra-libraries: z
> -
> if os(windows)
> hs-source-dirs: src/win32
> include-dirs: src/win32
> hunk ./darcs.cabal 346
> build-depends: mmap >= 0.2
> cpp-options: -DHAVE_MMAP
>
> - if flag(zlib)
> - build-depends: zlib >= 0.5.1.0 && < 0.6.0.0
> - cpp-options: -DHAVE_HASKELL_ZLIB
> - else
> - extra-libraries: z
> + build-depends: zlib >= 0.5.1.0 && < 0.6.0.0
>
> -- The terminfo package cannot be built on Windows.
> if flag(terminfo) && !os(windows)
> hunk ./darcs.cabal 396
> ghc-options: -Wall -O2 -funbox-strict-fields -threaded
> ghc-prof-options: -prof -auto-all
>
> - if !flag(zlib)
> - extra-libraries: z
> -
> cc-options: -D_REENTRANT
>
> if os(windows)
> hunk ./darcs.cabal 460
> build-depends: mmap >= 0.2
> cpp-options: -DHAVE_MMAP
>
> - if flag(zlib)
> - build-depends: zlib >= 0.5.1.0 && < 0.6.0.0
> - cpp-options: -DHAVE_HASKELL_ZLIB
> - else
> - extra-libraries: z
> + build-depends: zlib >= 0.5.1.0 && < 0.6.0.0
>
> -- The terminfo package cannot be built on Windows.
> if flag(terminfo) && !os(windows)
> hunk ./darcs.cabal 527
> test-framework-quickcheck2 >= 0.2.2
>
>
> - if !flag(zlib)
> - extra-libraries: z
> -
> cc-options: -D_REENTRANT
>
> if os(windows)
> hunk ./darcs.cabal 558
> build-depends: mmap >= 0.2
> cpp-options: -DHAVE_MMAP
>
> - if flag(zlib)
> - build-depends: zlib >= 0.5.1.0 && < 0.6.0.0
> - cpp-options: -DHAVE_HASKELL_ZLIB
> - else
> - extra-libraries: z
> + build-depends: zlib >= 0.5.1.0 && < 0.6.0.0
>
> -- The terminfo package cannot be built on Windows.
> if flag(terminfo) && !os(windows)
> hunk ./src/ByteStringUtils.hs 31
>
> -- gzip handling
> isGZFile,
> -#ifdef HAVE_HASKELL_ZLIB
> gzDecompress,
> hunk ./src/ByteStringUtils.hs 32
> -#endif
>
> -- list utilities
> ifHeadThenTail,
> hunk ./src/ByteStringUtils.hs 60
> import Data.ByteString (intercalate, uncons)
> import Data.ByteString.Internal (fromForeignPtr)
>
> -#if defined (HAVE_MMAP) || ! defined (HAVE_HASKELL_ZLIB)
> +#if defined (HAVE_MMAP)
> import Control.Exception ( catch )
> #endif
> import System.IO
> hunk ./src/ByteStringUtils.hs 77
> import Data.Int ( Int32 )
> import Control.Monad ( when )
>
> -#ifndef HAVE_HASKELL_ZLIB
> -import Foreign.Ptr ( nullPtr )
> -import Foreign.ForeignPtr ( ForeignPtr )
> -#endif
> import Foreign.Ptr ( plusPtr, Ptr )
> import Foreign.ForeignPtr ( withForeignPtr )
>
> hunk ./src/ByteStringUtils.hs 85
> import Foreign.Ptr ( FunPtr )
> #endif
>
> -#if HAVE_HASKELL_ZLIB
> import qualified Data.ByteString.Lazy as BL
> import qualified Codec.Compression.GZip as GZ
> import qualified Codec.Compression.Zlib.Internal as ZI
> hunk ./src/ByteStringUtils.hs 89
> import Darcs.Global ( addCRCWarning )
> -#else
> -import Foreign.C.String ( CString, withCString )
> -#endif
>
> #ifdef HAVE_MMAP
> import System.IO.MMap( mmapFileByteString )
> hunk ./src/ByteStringUtils.hs 99
> -- -----------------------------------------------------------------------------
> -- obsolete debugging code
>
> -# ifndef HAVE_HASKELL_ZLIB
> -debugForeignPtr :: ForeignPtr a -> String -> IO ()
> -#ifdef DEBUG_PS
> -foreign import ccall unsafe "static fpstring.h debug_alloc" debug_alloc
> - :: Ptr a -> CString -> IO ()
> -foreign import ccall unsafe "static fpstring.h & debug_free" debug_free
> - :: FunPtr (Ptr a -> IO ())
> -debugForeignPtr fp n =
> - withCString n $ \cname-> withForeignPtr fp $ \p->
> - do debug_alloc p cname
> - addForeignPtrFinalizer debug_free fp
> -#else
> -debugForeignPtr _ _ = return ()
> -#endif
> -#endif
> -
> -- -----------------------------------------------------------------------------
> -- unsafeWithInternals
>
> hunk ./src/ByteStringUtils.hs 320
> -- -----------------------------------------------------------------------------
> -- gzReadFilePS
>
> -#ifdef HAVE_HASKELL_ZLIB
> -
> -- |Decompress the given bytestring into a lazy list of chunks, along with a boolean
> -- flag indicating (if True) that the CRC was corrupted.
> -- Inspecting the flag will cause the entire list of chunks to be evaluated (but if
> hunk ./src/ByteStringUtils.hs 353
> handleBad ZI.DataError "incorrect data check" = ([], True)
> handleBad _ msg = error msg
>
> -#else
> -
> -foreign import ccall unsafe "static zlib.h gzopen" c_gzopen
> - :: CString -> CString -> IO (Ptr ())
> -foreign import ccall unsafe "static zlib.h gzclose" c_gzclose
> - :: Ptr () -> IO ()
> -foreign import ccall unsafe "static zlib.h gzread" c_gzread
> - :: Ptr () -> Ptr Word8 -> CInt -> IO CInt
> -foreign import ccall unsafe "static zlib.h gzwrite" c_gzwrite
> - :: Ptr () -> Ptr Word8 -> CInt -> IO CInt
> -
> -#endif
> -
> isGZFile :: FilePath -> IO (Maybe Int)
> isGZFile f = do
> h <- openBinaryFile f ReadMode
> hunk ./src/ByteStringUtils.hs 373
> case mlen of
> Nothing -> mmapFilePS f
> Just len ->
> -#ifdef HAVE_HASKELL_ZLIB
> do -- Passing the length to gzDecompress means that it produces produces one chunk,
> -- which in turn means that B.concat won't need to copy data.
> -- If the length is wrong this will just affect efficiency, not correctness
> hunk ./src/ByteStringUtils.hs 381
> return res
> compressed <- (BL.fromChunks . return) `fmap` mmapFilePS f
> B.concat `fmap` doDecompress compressed
> -#else
> - withCString f $ \fstr-> withCString "rb" $ \rb-> do
> - gzf <- c_gzopen fstr rb
> - when (gzf == nullPtr) $ fail $ "problem opening file "++f
> - fp <- BI.mallocByteString len
> - debugForeignPtr fp $ "gzReadFilePS "++f
> - lread <- withForeignPtr fp $ \p ->
> - c_gzread gzf p (fromIntegral len)
> - c_gzclose gzf
> - when (fromIntegral lread /= len) $
> - fail $ "problem gzreading file "++f
> - return $ fromForeignPtr fp 0 len
> -#endif
>
> hGetLittleEndInt :: Handle -> IO Int
> hGetLittleEndInt h = do
> hunk ./src/ByteStringUtils.hs 395
>
> gzWriteFilePSs :: FilePath -> [B.ByteString] -> IO ()
> gzWriteFilePSs f pss =
> -#ifdef HAVE_HASKELL_ZLIB
> BL.writeFile f $ GZ.compress $ BL.fromChunks pss
> hunk ./src/ByteStringUtils.hs 396
> -#else
> - withCString f $ \fstr -> withCString "wb" $ \wb -> do
> - gzf <- c_gzopen fstr wb
> - when (gzf == nullPtr) $ fail $ "problem gzopening file for write: "++f
> - mapM_ (gzWriteToGzf gzf) pss `catch`
> - \_ -> fail $ "problem gzwriting file: "++f
> - c_gzclose gzf
> -
> -gzWriteToGzf :: Ptr () -> B.ByteString -> IO ()
> -gzWriteToGzf gzf ps = case BI.toForeignPtr ps of
> - (_,_,0) -> return () -- avoid calling gzwrite with 0 length this would
> - -- trouble on some versions of zlib, and is always
> - -- unnecessary.
> - (x,s,l) -> do
> - lw <- withForeignPtr x $ \p -> c_gzwrite gzf (p `plusPtr` s)
> - (fromIntegral l)
> - when (fromIntegral lw /= l) $ fail $ "problem in gzWriteToGzf"
> -#endif
>
> -- -----------------------------------------------------------------------------
> -- mmapFilePS
> hunk ./src/Darcs/Commands/GZCRCs.lhs 55
> import Darcs.Repository.Cache ( Cache(..), writable, isthisrepo, hashedFilePath, allHashedDirs )
>
>
> -#ifdef HAVE_HASKELL_ZLIB
> import Darcs.Global ( getCRCWarnings, resetCRCWarnings )
> import ByteStringUtils ( gzDecompress )
> hunk ./src/Darcs/Commands/GZCRCs.lhs 57
> -#else
> --- These functions aren't available unless we have the Haskell zlib.
> --- The gzcrcs command shouldn't be enabled in this case, but we would
> --- still like to typecheck this module as much as possible so we include
> --- dummy versions
> -noChecking :: String -> a
> -noChecking what = error $ "Darcs.Commands.GZCRCs." ++ what ++ ": gz CRC checking is not possible unless " ++
> - "darcs has been built with the Haskell zlib. This code should be unreachable."
> -getCRCWarnings :: IO [FilePath]
> -getCRCWarnings = noChecking "getCRCWarnings"
> -resetCRCWarnings :: IO ()
> -resetCRCWarnings = noChecking "resetCRCWarnings"
> -gzDecompress :: Maybe Int -> BL.ByteString -> ([B.ByteString], Bool)
> -gzDecompress = noChecking "gzDecompress"
> -#endif
>
> gzcrcs_description :: String
> gzcrcs_description = "Check or repair the CRCs of compressed files in the repository."
> hunk ./src/Darcs/Global.hs 29
> timingsMode, setTimingsMode,
> whenDebugMode, withDebugMode, setDebugMode,
> debugMessage, debugFail, putTiming,
> -#ifdef HAVE_HASKELL_ZLIB
> addCRCWarning, getCRCWarnings, resetCRCWarnings,
> hunk ./src/Darcs/Global.hs 30
> -#endif
> darcsdir
> ) where
>
> hunk ./src/Darcs/Global.hs 37
> import Control.Concurrent.MVar
> import Control.Exception (bracket_, catch, block, unblock)
> import Data.IORef ( IORef, newIORef, readIORef, writeIORef )
> -#ifdef HAVE_HASKELL_ZLIB
> import Data.IORef ( modifyIORef )
> hunk ./src/Darcs/Global.hs 38
> -#endif
> import System.IO.Unsafe (unsafePerformIO)
> import System.IO (hPutStrLn, hPutStr, stderr)
> import System.Time ( calendarTimeToString, toCalendarTime, getClockTime )
> hunk ./src/Darcs/Global.hs 138
> sshControlMasterDisabled :: Bool
> sshControlMasterDisabled = unsafePerformIO $ readIORef _sshControlMasterDisabled
>
> -#ifdef HAVE_HASKELL_ZLIB
> type CRCWarningList = [FilePath]
> {-# NOINLINE _crcWarningList #-}
> _crcWarningList :: IORef CRCWarningList
> hunk ./src/Darcs/Global.hs 151
>
> resetCRCWarnings :: IO ()
> resetCRCWarnings = writeIORef _crcWarningList []
> -#endif
>
> darcsdir :: String
> darcsdir = "_darcs"
> hunk ./src/Darcs/RunCommand.hs 48
> extract_commands,
> super_name,
> subusage, chomp_newline )
> -#ifdef HAVE_HASKELL_ZLIB
> import Darcs.Commands.GZCRCs ( doCRCWarnings )
> import Darcs.Global ( atexit )
> hunk ./src/Darcs/RunCommand.hs 50
> -#endif
> import Darcs.Commands.Help ( command_control_list )
> import Darcs.External ( viewDoc )
> import Darcs.Global ( setDebugMode, setSshControlMasterDisabled,
> hunk ./src/Darcs/RunCommand.hs 136
> when (HTTPPipelining `elem` os) $ setHTTPPipelining True
> when (NoHTTPPipelining `elem` os) $ setHTTPPipelining False
> unless (SSHControlMaster `elem` os) setSshControlMasterDisabled
> -#ifdef HAVE_HASKELL_ZLIB
> unless (Quiet `elem` os) $ atexit $ doCRCWarnings (Verbose `elem` os)
> hunk ./src/Darcs/RunCommand.hs 137
> -#endif
> -- actually run the command and its hooks
> preHookExitCode <- run_prehook os here
> if preHookExitCode /= ExitSuccess
> hunk ./src/Darcs/TheCommands.hs 31
> import Darcs.Commands.Diff
> import Darcs.Commands.Dist ( dist )
> import Darcs.Commands.Get ( get, clone )
> -#ifdef HAVE_HASKELL_ZLIB
> import Darcs.Commands.GZCRCs ( gzcrcs )
> hunk ./src/Darcs/TheCommands.hs 32
> -#else
> --- import just to check it compiles
> -import Darcs.Commands.GZCRCs ()
> -#endif
> import Darcs.Commands.Init ( initialize )
> import Darcs.Commands.Show ( show_command, list, query )
> import Darcs.Commands.MarkConflicts ( markconflicts, resolve )
> hunk ./src/Darcs/TheCommands.hs 99
> Command_data check,
> Command_data repair,
> Command_data convert
> -#ifdef HAVE_HASKELL_ZLIB
> ,Hidden_command gzcrcs
> hunk ./src/Darcs/TheCommands.hs 100
> -#endif
> ]
>
--
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090722/be5cc101/attachment.pgp>
More information about the darcs-users
mailing list