From 31b3f2ef8861a8af6c146a8c6f770c6165311fc2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 9 May 2015 22:28:49 -0700 Subject: ImageSize: Use runGetOrFail with binary 0.7+. --- src/Text/Pandoc/ImageSize.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs index b4e94da0f..21023b62d 100644 --- a/src/Text/Pandoc/ImageSize.hs +++ b/src/Text/Pandoc/ImageSize.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} {- Copyright (C) 2011-2015 John MacFarlane @@ -195,8 +195,19 @@ findJfifSize bs = _ -> Left "JFIF parse error" Nothing -> Left "Did not find JFIF length record" +runGet' :: Get (Either String a) -> BL.ByteString -> Either String a +runGet' p bl = +#if MIN_VERSION_binary(0,7,0) + case runGetOrFail p bl of + Left (_,_,msg) -> Left msg + Right (_,_,x) -> x +#else + runGet p bl +#endif + + exifSize :: ByteString -> Either String ImageSize -exifSize bs = runGet header $ bl +exifSize bs = runGet' header $ bl where bl = BL.fromChunks [bs] header = runExceptT $ exifHeader bl -- NOTE: It would be nicer to do -- cgit v1.2.3