This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-core".
The branch, master has been updated
via 240825476e22a6c51e5dc34352020992f5e326a2 (commit)
via bf4a279e419753eb3d254af6eab016f22c0ba17c (commit)
via 5493800ccb946ab35619c8d3d4104a4275036bac (commit)
from 6cfc5bb3273a7f2e8842f21726f2550424cf46a9 (commit)
Summary of changes:
snap-core.cabal | 13 ++++++---
src/Snap/Internal/Http/Types.hs | 54 ++++++++++++++++++++++++++------------
src/Snap/Iteratee.hs | 28 ++++++++++++++++++-
src/Snap/Starter.hs | 2 +-
src/Snap/Util/FileServe.hs | 3 +-
test/snap-core-testsuite.cabal | 12 ++++++---
6 files changed, 82 insertions(+), 30 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 240825476e22a6c51e5dc34352020992f5e326a2
Merge: 6cfc5bb bf4a279
Author: Gregory Collins <[email protected]>
Date: Wed May 26 21:31:12 2010 -0400
Merge branch 'master' of http://github.com/jystic/snap-core
commit bf4a279e419753eb3d254af6eab016f22c0ba17c
Author: Jacob Stanley <[email protected]>
Date: Thu May 27 01:40:48 2010 +0800
Running 'snap init' now writes the 'project.cabal' file correctly under
Windows
diff --git a/src/Snap/Starter.hs b/src/Snap/Starter.hs
index 22d829b..9bc319c 100644
--- a/src/Snap/Starter.hs
+++ b/src/Snap/Starter.hs
@@ -4,7 +4,7 @@ module Main where
import System
import System.Directory
import System.Console.GetOpt
-import System.FilePath.Posix
+import System.FilePath
------------------------------------------------------------------------------
commit 5493800ccb946ab35619c8d3d4104a4275036bac
Author: Jacob Stanley <[email protected]>
Date: Mon May 24 03:44:00 2010 +0800
Compiles and runs all tests successfully on Windows
Some the performance improvements which were added in
c643e0cec421f6af4b6985ad85d980cbbfc3b0c8 were reverted
conditionally based on the platform being WIN32.
The C functions mmap, strptime and gmtime_r are not
available on windows.
diff --git a/snap-core.cabal b/snap-core.cabal
index 080c406..533652c 100644
--- a/snap-core.cabal
+++ b/snap-core.cabal
@@ -109,8 +109,12 @@ Library
if flag(testsuite)
cpp-options: -DDEBUG_TEST
- c-sources: cbits/timefuncs.c
- include-dirs: cbits
+ if os(windows)
+ cpp-options: -DWIN32
+ else
+ c-sources: cbits/timefuncs.c
+ include-dirs: cbits
+ build-depends: bytestring-mmap >= 0.2.1 && <0.3
exposed-modules:
Data.CIByteString,
@@ -130,7 +134,6 @@ Library
attoparsec >= 0.8.0.2 && < 0.9,
base >= 4 && < 5,
bytestring,
- bytestring-mmap >= 0.2.1 && <0.3,
bytestring-nums,
cereal >= 0.2 && < 0.3,
containers,
@@ -145,7 +148,7 @@ Library
text >= 0.7.1 && <0.8,
time,
transformers,
- unix,
+ unix-compat,
zlib
ghc-prof-options: -prof -auto-all
@@ -178,7 +181,7 @@ Executable snap
text >= 0.7.1 && <0.8,
time,
transformers,
- unix,
+ unix-compat,
zlib
ghc-prof-options: -prof -auto-all
diff --git a/src/Snap/Internal/Http/Types.hs b/src/Snap/Internal/Http/Types.hs
index 558a7af..4c451ec 100644
--- a/src/Snap/Internal/Http/Types.hs
+++ b/src/Snap/Internal/Http/Types.hs
@@ -5,6 +5,7 @@
-- unsafe/encapsulation-breaking ones) are re-exported from "Snap.Types".
{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE OverloadedStrings #-}
@@ -36,16 +37,23 @@ import Data.Time.Clock
import Data.Time.Format
import Data.Word
import Foreign hiding (new)
-import Foreign.C.String
import Foreign.C.Types
import Prelude hiding (take)
import System.Locale (defaultTimeLocale)
+#ifdef WIN32
+import Data.Time.Clock.POSIX
+#else
+import Foreign.C.String
+#endif
+
------------------------------------------------------------------------------
import Data.CIByteString
import qualified Snap.Iteratee as I
+#ifndef WIN32
+
------------------------------------------------------------------------------
foreign import ccall unsafe "set_c_locale"
set_c_locale :: IO ()
@@ -60,6 +68,8 @@ foreign import ccall unsafe "c_parse_http_time"
foreign import ccall unsafe "c_format_http_time"
c_format_http_time :: CTime -> CString -> IO ()
+#endif
+
------------------------------------------------------------------------------
type Enumerator a = I.Enumerator IO a
@@ -502,32 +512,42 @@ clearContentLength r = r { rspContentLength = Nothing }
------------------------------------------------------------------------------
-- HTTP dates
-{-
--- | Converts a 'ClockTime' into an HTTP timestamp.
-formatHttpTime :: UTCTime -> ByteString
-formatHttpTime = fromStr . formatTime defaultTimeLocale "%a, %d %b %Y %X GMT"
+-- | Converts a 'CTime' into an HTTP timestamp.
+formatHttpTime :: CTime -> IO ByteString
+
+-- | Converts an HTTP timestamp into a 'CTime'.
+parseHttpTime :: ByteString -> IO CTime
+
+#ifdef WIN32
--- | Converts an HTTP timestamp into a 'UTCTime'.
-parseHttpTime :: ByteString -> Maybe UTCTime
-parseHttpTime s' =
- parseTime defaultTimeLocale "%a, %d %b %Y %H:%M:%S GMT" s
+formatHttpTime = return . format . posixSecondsToUTCTime . toPOSIXTime
where
- s = toStr s'
--}
+ format :: UTCTime -> ByteString
+ format = fromStr . formatTime defaultTimeLocale "%a, %d %b %Y %X GMT"
+
+ toPOSIXTime :: CTime -> POSIXTime
+ toPOSIXTime = realToFrac
+
+parseHttpTime = return . toCTime . parse . toStr
+ where
+ parse :: String -> Maybe UTCTime
+ parse = parseTime defaultTimeLocale "%a, %d %b %Y %H:%M:%S GMT"
+
+ toCTime :: Maybe UTCTime -> CTime
+ toCTime (Just t) = fromInteger $ truncate $ utcTimeToPOSIXSeconds t
+ toCTime Nothing = fromInteger 0
+
+#else
--- | Converts a 'CTime' into an HTTP timestamp.
-formatHttpTime :: CTime -> IO ByteString
formatHttpTime t = allocaBytes 40 $ \ptr -> do
c_format_http_time t ptr
S.packCString ptr
-
-------------------------------------------------------------------------------
--- | Converts an HTTP timestamp into a 'CTime'.
-parseHttpTime :: ByteString -> IO CTime
parseHttpTime s = S.useAsCString s $ \ptr ->
c_parse_http_time ptr
+#endif
+
------------------------------------------------------------------------------
-- URL ENCODING
diff --git a/src/Snap/Iteratee.hs b/src/Snap/Iteratee.hs
index dcc6a0d..27ff427 100644
--- a/src/Snap/Iteratee.hs
+++ b/src/Snap/Iteratee.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances #-}
@@ -40,7 +41,6 @@ module Snap.Iteratee
) where
------------------------------------------------------------------------------
-import Control.Exception (SomeException)
import Control.Monad
import Control.Monad.CatchIO
import Data.ByteString (ByteString)
@@ -48,13 +48,22 @@ import qualified Data.ByteString as S
import qualified Data.ByteString.Unsafe as S
import qualified Data.ByteString.Lazy as L
import Data.Iteratee
+import Data.Iteratee.IO (enumHandle)
import qualified Data.Iteratee.Base.StreamChunk as SC
import Data.Iteratee.WrappedByteString
import Data.Monoid (mappend)
import Foreign
import Prelude hiding (catch,drop)
-import System.IO.Posix.MMap
import qualified Data.DList as D
+
+#ifdef WIN32
+import Control.Monad.Trans (liftIO)
+import System.IO
+#else
+import Control.Exception (SomeException)
+import System.IO.Posix.MMap
+#endif
+
------------------------------------------------------------------------------
type Stream = StreamG WrappedByteString Word8
@@ -332,6 +341,19 @@ takeNoMoreThan n' iter =
------------------------------------------------------------------------------
enumFile :: FilePath -> Iteratee IO a -> IO (Iteratee IO a)
+
+#ifdef WIN32
+
+enumFile fp iter = do
+ h <- liftIO $ openBinaryFile fp ReadMode
+ i' <- enumHandle h iter
+ return $ do
+ x <- i'
+ liftIO (hClose h)
+ return x
+
+#else
+
enumFile fp iter = do
es <- (try $
liftM WrapBS $
@@ -340,3 +362,5 @@ enumFile fp iter = do
case es of
(Left e) -> return $ throwErr $ Err $ "IO error" ++ show e
(Right s) -> liftM liftI $ runIter iter $ Chunk s
+
+#endif
diff --git a/src/Snap/Util/FileServe.hs b/src/Snap/Util/FileServe.hs
index f7e977d..63bead3 100644
--- a/src/Snap/Util/FileServe.hs
+++ b/src/Snap/Util/FileServe.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
@@ -23,7 +24,7 @@ import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import System.Directory
import System.FilePath
-import System.Posix.Files
+import System.PosixCompat.Files
------------------------------------------------------------------------------
import Snap.Types
diff --git a/test/snap-core-testsuite.cabal b/test/snap-core-testsuite.cabal
index dd5f37a..eee6855 100644
--- a/test/snap-core-testsuite.cabal
+++ b/test/snap-core-testsuite.cabal
@@ -13,8 +13,6 @@ Flag testsuite
Default: False
Executable testsuite
- c-sources: ../cbits/timefuncs.c
- include-dirs: ../cbits
hs-source-dirs: ../src suite
main-is: TestSuite.hs
@@ -24,12 +22,18 @@ Executable testsuite
if flag(testsuite)
cpp-options: -DDEBUG_TEST
+ if os(windows)
+ cpp-options: -DWIN32
+ else
+ c-sources: ../cbits/timefuncs.c
+ include-dirs: ../cbits
+ build-depends: bytestring-mmap >= 0.2.1 && <0.3
+
build-depends:
QuickCheck >= 2,
attoparsec >= 0.8.0.2 && < 0.9,
base >= 4 && < 5,
bytestring,
- bytestring-mmap >= 0.2.1 && <0.3,
bytestring-nums,
cereal >= 0.2 && < 0.3,
containers,
@@ -49,7 +53,7 @@ Executable testsuite
text >= 0.7.1 && <0.8,
time,
transformers,
- unix,
+ unix-compat,
zlib
ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded
-----------------------------------------------------------------------
hooks/post-receive
--
snap-core
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap