aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-05-09 22:28:49 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-05-09 22:28:49 -0700
commit31b3f2ef8861a8af6c146a8c6f770c6165311fc2 (patch)
tree5bf458534b45f747b3784e9cecaa048c28dafcef /src/Text
parenta60c65c4e9621156983bdf1adad9b00da4aadf50 (diff)
downloadpandoc-31b3f2ef8861a8af6c146a8c6f770c6165311fc2.tar.gz
ImageSize: Use runGetOrFail with binary 0.7+.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/ImageSize.hs15
1 files changed, 13 insertions, 2 deletions
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 <jgm@berkeley.edu>
@@ -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