1
1
mirror of https://github.com/gelisam/hawk.git synced 2024-12-03 03:53:58 +03:00

fix spurious extra row

lines are terminated by "\n", not separated by "\n", so treat the "\n"
separator as a special case.
This commit is contained in:
Samuel Gélineau 2014-02-28 21:12:06 -05:00
parent d8ace91c2c
commit 2a1308b5ad

View File

@ -54,11 +54,8 @@ splitIntoTable (Lines sep format) = fmap splitIntoFields' . splitIntoLines'
-- [line0, line1, ...]
splitIntoLines :: Separator -> B.ByteString -> [B.ByteString]
splitIntoLines sep = fmap postprocess . Search.split sep
splitIntoLines "\n" = fmap dropWindowsNewline . B.lines
where
postprocess | sep == "\n" = dropWindowsNewline
| otherwise = id
dropWindowsNewline :: B.ByteString -> B.ByteString
dropWindowsNewline "" = ""
dropWindowsNewline s
@ -68,6 +65,7 @@ splitIntoLines sep = fmap postprocess . Search.split sep
last_char = B.last s
n = B.length s
s' = B.take (n - 1) s
splitIntoLines sep = Search.split sep
-- [line]
-- or