~singpolyma/haskell-libxml-sax

dba80d765695b9b0fdb176e62cc92151ec49db83 — John Millikin 13 years ago 0f4c096
stylistic
1 files changed, 6 insertions(+), 8 deletions(-)

M Text/XML/LibXML/SAX.hs
M Text/XML/LibXML/SAX.hs => Text/XML/LibXML/SAX.hs +6 -8
@@ 51,7 51,7 @@ module Text.XML.LibXML.SAX
	) where

import qualified Control.Exception as E
import           Control.Monad (unless)
import           Control.Monad (when, unless)
import qualified Control.Monad.ST as ST
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as BU


@@ 150,13 150,11 @@ clearCallback p (Callback _ clear) = parserFromIO p (clear p)
catchRef :: Parser m -> Ptr Context -> m Bool -> IO ()
catchRef p cb_ctx io = withParserIO p $ \ctx ->
	(cWantCallback ctx cb_ctx >>=) $ \want ->
	if want == 1
		then do
			continue <- E.catch (E.unblock (parserToIO p io)) $ \e -> do
				writeIORef (parserErrorRef p) (Just e)
				return False
			unless continue (cStopParser ctx)
		else return ()
	when (want == 1) $ do
		continue <- E.catch (E.unblock (parserToIO p io)) $ \e -> do
			writeIORef (parserErrorRef p) (Just e)
			return False
		unless continue (cStopParser ctx)

catchRefIO :: Parser m -> Ptr Context -> IO Bool -> IO ()
catchRefIO p cb_ctx io = catchRef p cb_ctx (parserFromIO p io)