-- | Expand FontForge .cidmap entry
--
-- Examples:
--
-- >>> expandEntry [] "62..63 005d"
-- (Range 62 63,Uni ']')
--
-- >>> expandEntry [] "0 /.notdef"
-- (CID 0,NOTDEF)
--
-- >>> expandEntry [] "1 0020,00a0"
-- (CID 1,Variation "\160 ")
--
-- >>> expandEntry [] "124 /uni2026.dup1"
-- (CID 124,Dup '\8230' 1)
--
-- >>> expandEntry ["646 ff40"] "390 /Japan1.646.hw"
-- (CID 390,Hw '\65344')

expandEntry :: [String] -> String -> (FFE, FFC)
expandEntry ffmap s = let (cids, val) = break (==' ') s
                          ffe = if ".." `isInfixOf` cids
                                then mkrange 
                                     (takeWhile isDigit cids) $  
                                     (dropWhile (=='.') . dropWhile isDigit) cids
                                else CID (read cids :: Int)
                          ffc = readFFValue ffmap $ dropWhile (==' ') val
                      in (ffe, ffc)
  where mkrange s s' = Range (read s :: Int) (read s' :: Int)
expandEntry :: [String] -> String -> (FFE, FFC)
expandEntry ffmap s = let (cids, val) = break (==' ') s
                          ffe = if ".." `isInfixOf` cids
                                then mkrange 
                                     (takeWhile isDigit cids) $  
                                     (dropWhile (=='.') . dropWhile isDigit) cids
                                else CID (read cids :: Int)
                          ffc = readFFValue ffmap $ dropWhile (==' ') val
                      in (ffe, ffc)
  where mkrange s s' = Range (read s :: Int) (read s' :: Int)
expandEntry ffmap s = let (cids, val) = break (==' ') s
                          ffe = if ".." `isInfixOf` cids
                                then mkrange 
                                     (takeWhile isDigit cids) $  
                                     (dropWhile (=='.') . dropWhile isDigit) cids
                                else CID (read cids :: Int)
                          ffc = readFFValue ffmap $ dropWhile (==' ') val
                      in (ffe, ffc)
  where mkrange s s' = Range (read s :: Int) (read s' :: Int)