~alcinnz/fontconfig-pure

3598fc24625f233cc0078f62da630d335604ef5b — Adrian Cochrane 2 years ago 5aedd01
Add more unboxing & null-checks to FcValue decoding.
1 files changed, 14 insertions(+), 6 deletions(-)

M Graphics/Text/Font/Choose/Value.hs
M Graphics/Text/Font/Choose/Value.hs => Graphics/Text/Font/Choose/Value.hs +14 -6
@@ 102,16 102,24 @@ thawValue ptr = do
        0 -> return $ Just ValueVoid
        1 -> Just <$> ValueInt <$> peek val'
        2 -> Just <$> ValueDouble <$> peek val'
        3 -> Just <$> ValueString <$> peekCString val'
        3 -> do
            val <- throwNull <$> peek val'
            Just <$> ValueString <$> peekCString val
        4 -> do
            mat' <- peek val'
            mat' <- throwNull <$> peek val'
            xx <- peekElemOff mat' 0
            xy <- peekElemOff mat' 1
            yx <- peekElemOff mat' 2
            yy <- peekElemOff mat' 3
            return $ Just $ ValueMatrix $ V2 (V2 xx yx) (V2 xy yy)
        5 -> Just <$> ValueCharSet <$> thawCharSet val'
        6 -> return $ Just $ ValueFTFace $ val'
        7 -> Just <$> ValueLangSet <$> thawLangSet val'
        8 -> Just <$> ValueRange <$> thawRange val'
        5 -> do
            val <- throwNull <$> peek val'
            Just <$> ValueCharSet <$> thawCharSet val
        6 -> Just <$> ValueFTFace <$> throwNull <$> peek val'
        7 -> do
            val <- throwNull <$> peek val'
            Just <$> ValueLangSet <$> thawLangSet val
        8 -> do
            val <- throwNull <$> peek val'
            Just <$> ValueRange <$> thawRange val
        _ -> return Nothing