diff options
author | Joey Hess <joeyh@joeyh.name> | 2023-08-14 12:06:32 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2023-08-14 12:12:52 -0400 |
commit | edf83982be214f3c839fab9b659f645de53a9100 (patch) | |
tree | bef06cb750379c6d7942fc13b13fcb328201354c /Utility/Misc.hs | |
parent | f0cd3a2a3758ddcd2f0900c16bdc1fb80bbd6e92 (diff) | |
download | git-repair-edf83982be214f3c839fab9b659f645de53a9100.tar.gz |
merge from git-annex
Support building with unix-compat 0.7
Diffstat (limited to 'Utility/Misc.hs')
-rw-r--r-- | Utility/Misc.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Utility/Misc.hs b/Utility/Misc.hs index 01ae178..3cf5275 100644 --- a/Utility/Misc.hs +++ b/Utility/Misc.hs @@ -12,6 +12,7 @@ module Utility.Misc ( readFileStrict, separate, separate', + separateEnd', firstLine, firstLine', segment, @@ -62,6 +63,13 @@ separate' c l = unbreak $ S.break c l | S.null b = r | otherwise = (a, S.tail b) +separateEnd' :: (Word8 -> Bool) -> S.ByteString -> (S.ByteString, S.ByteString) +separateEnd' c l = unbreak $ S.breakEnd c l + where + unbreak r@(a, b) + | S.null a = r + | otherwise = (S.init a, b) + {- Breaks out the first line. -} firstLine :: String -> String firstLine = takeWhile (/= '\n') @@ -86,7 +94,7 @@ prop_segment_regressionTest :: Bool prop_segment_regressionTest = all id -- Even an empty list is a segment. [ segment (== "--") [] == [[]] - -- There are two segements in this list, even though the first is empty. + -- There are two segments in this list, even though the first is empty. , segment (== "--") ["--", "foo", "bar"] == [[],["foo","bar"]] ] |