Created
November 30, 2011 13:05
-
-
Save tsurushuu/1408993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System | |
import Data.List | |
import Control.Monad | |
separateDiffPatch :: String -> [String] | |
separateDiffPatch str = map unlines . map (head . filter patchEnd . inits) . (filter patchStart . tails) . lines $ str | |
where | |
patchStart (l0 : l1 : l2 : ls) = and [isPrefixOf "From " l0, isPrefixOf "From: " l1, isPrefixOf "Date: " l2] | |
patchStart _ = False | |
-- | |
patchEnd ss = isSuffixOf ["1.7.5.1", ""] ss | |
main = do | |
args <- getArgs | |
let fn = args !! 0 | |
contents <- readFile fn | |
let eachFNs = map (\n -> fn ++ "." ++ show n) [1..] | |
let eachPatches = separateDiffPatch contents | |
zipWithM (writeFile) eachFNs eachPatches | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment