Patch for compiling with 6.10 (define NEW_EXCEPTIONS to do that)
authorunc0rr
Wed, 05 Aug 2009 05:44:13 +0000
changeset 2296 19f2f76dc346
parent 2295 2fff3e4ce52f
child 2297 ac0dd1622b19
Patch for compiling with 6.10 (define NEW_EXCEPTIONS to do that) Not tested
gameServer/ClientIO.hs
gameServer/NetRoutines.hs
gameServer/OfficialServer/DBInteraction.hs
gameServer/hedgewars-server.hs
--- a/gameServer/ClientIO.hs	Wed Aug 05 05:37:17 2009 +0000
+++ b/gameServer/ClientIO.hs	Wed Aug 05 05:44:13 2009 +0000
@@ -1,7 +1,11 @@
-{-# LANGUAGE PatternSignatures #-}
+{-# LANGUAGE CPP, PatternSignatures #-}
 module ClientIO where
 
-import qualified Control.Exception
+#if defined(NEW_EXCEPTIONS)
+import qualified Control.OldException as Exception
+#else
+import qualified Control.Exception as Exception
+#endif
 import Control.Concurrent.Chan
 import Control.Monad
 import System.IO
@@ -29,15 +33,15 @@
 clientSendLoop :: Handle -> Chan CoreMessage -> Chan [String] -> Int -> IO()
 clientSendLoop handle coreChan chan clientID = do
 	answer <- readChan chan
-	doClose <- Control.Exception.handle
-		(\(e :: Control.Exception.Exception) -> if isQuit answer then return True else sendQuit e >> return False) $ do
+	doClose <- Exception.handle
+		(\(e :: Exception.Exception) -> if isQuit answer then return True else sendQuit e >> return False) $ do
 		forM_ answer (\str -> hPutStrLn handle str)
 		hPutStrLn handle ""
 		hFlush handle
 		return $ isQuit answer
 
 	if doClose then
-		Control.Exception.handle (\(_ :: Control.Exception.Exception) -> putStrLn "error on hClose") $ hClose handle
+		Exception.handle (\(_ :: Exception.Exception) -> putStrLn "error on hClose") $ hClose handle
 		else
 		clientSendLoop handle coreChan chan clientID
 
--- a/gameServer/NetRoutines.hs	Wed Aug 05 05:37:17 2009 +0000
+++ b/gameServer/NetRoutines.hs	Wed Aug 05 05:44:13 2009 +0000
@@ -1,4 +1,4 @@
-{-# LANGUAGE PatternSignatures #-}
+{-# LANGUAGE CPP, PatternSignatures #-}
 module NetRoutines where
 
 import Network
@@ -7,7 +7,11 @@
 import Control.Concurrent
 import Control.Concurrent.Chan
 import Control.Concurrent.STM
-import Control.Exception
+#if defined(NEW_EXCEPTIONS)
+import qualified Control.OldException as Exception
+#else
+import qualified Control.Exception as Exception
+#endif
 import Data.Time
 -----------------------------
 import CoreTypes
@@ -16,8 +20,8 @@
 
 acceptLoop :: Socket -> Chan CoreMessage -> Int -> IO ()
 acceptLoop servSock coreChan clientCounter = do
-	Control.Exception.handle
-		(\(_ :: Exception) -> putStrLn "exception on connect") $
+	Exception.handle
+		(\(_ :: Exception.Exception) -> putStrLn "exception on connect") $
 		do
 		(socket, sockAddr) <- Network.Socket.accept servSock
 
--- a/gameServer/OfficialServer/DBInteraction.hs	Wed Aug 05 05:37:17 2009 +0000
+++ b/gameServer/OfficialServer/DBInteraction.hs	Wed Aug 05 05:44:13 2009 +0000
@@ -8,7 +8,11 @@
 import System.Process
 import System.IO
 import Control.Concurrent
-import Control.Exception
+#if defined(NEW_EXCEPTIONS)
+import qualified Control.OldException as Exception
+#else
+import qualified Control.Exception as Exception
+#endif
 import Control.Monad
 import qualified Data.Map as Map
 import Monad
@@ -44,7 +48,7 @@
 
 
 pipeDbConnectionLoop queries coreChan hIn hOut accountsCache =
-	Control.Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $
+	Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $
 	do
 	q <- readChan queries
 	updatedCache <- case q of
@@ -83,7 +87,7 @@
 
 pipeDbConnection accountsCache serverInfo = do
 	updatedCache <-
-		Control.Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $ do
+		Exception.handle (\e -> warningM "Database" (show e) >> return accountsCache) $ do
 			(Just hIn, Just hOut, _, _) <- createProcess (proc "./OfficialServer/extdbinterface" [])
 					{std_in = CreatePipe,
 					std_out = CreatePipe}
--- a/gameServer/hedgewars-server.hs	Wed Aug 05 05:37:17 2009 +0000
+++ b/gameServer/hedgewars-server.hs	Wed Aug 05 05:44:13 2009 +0000
@@ -6,7 +6,11 @@
 import qualified Network
 import Control.Concurrent.STM
 import Control.Concurrent.Chan
-import Control.Exception
+#if defined(NEW_EXCEPTIONS)
+import qualified Control.OldException as Exception
+#else
+import qualified Control.Exception as Exception
+#endif
 import System.Log.Logger
 -----------------------------------
 import Opts
@@ -47,7 +51,7 @@
 	let serverInfo = serverInfo'
 #endif
 
-	bracket
+	Exception.bracket
 		(Network.listenOn $ Network.PortNumber $ listenPort serverInfo)
 		(sClose)
 		(startServer serverInfo)