git.iko.soy/typeable/pandoc
on master help sign in
Avoid non-exhaustive pattern match.
0ae7927John MacFarlane
src/Text/Pandoc/ImageSize.hs+12−11
@@ -410,20 +410,21 @@ jpegSize img =
410
410
411jfifSize :: ByteString -> Either String ImageSize
411jfifSize :: ByteString -> Either String ImageSize
412jfifSize rest =
412jfifSize rest =
413− let [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] = map fromIntegral
414− $ unpack $ B.take 5 $B.drop 9 rest
413+ case map fromIntegral $ unpack $ B.take 5 $ B.drop 9 rest of
414+ [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] ->
415− factor = case dpiDensity of
415+ let factor = case dpiDensity of
416− 1 -> id
416+ 1 -> id
417− 2 -> \x -> x * 254 `div` 10
417+ 2 -> \x -> x * 254 `div` 10
418− _ -> const 72
418+ _ -> const 72
419− dpix = factor (shift dpix1 8 + dpix2)
419+ dpix = factor (shift dpix1 8 + dpix2)
420− dpiy = factor (shift dpiy1 8 + dpiy2)
420+ dpiy = factor (shift dpiy1 8 + dpiy2)
421− in case findJfifSize rest of
421+ in case findJfifSize rest of
422− Left msg -> Left msg
422+ Left msg -> Left msg
423− Right (w,h) ->Right ImageSize { pxX = w
423+ Right (w,h) -> Right ImageSize { pxX = w
424 , pxY = h
424 , pxY = h
425 , dpiX = dpix
425 , dpiX = dpix
426 , dpiY = dpiy }
426 , dpiY = dpiy }
427+ _ -> Left "unable to determine JFIF size"
427
428
428findJfifSize :: ByteString -> Either String (Integer,Integer)
429findJfifSize :: ByteString -> Either String (Integer,Integer)
429findJfifSize bs =
430findJfifSize bs =