cgrep 6.4.5 → 6.4.6
raw patch · 5 files changed
+22/−21 lines, 5 filesdep +eitherdep +mtl
Dependencies added: either, mtl
Files
- README.md +1/−1
- cgrep.cabal +3/−1
- src/CGrep/Lang.hs +1/−1
- src/Config.hs +1/−1
- src/Main.hs +16/−17
README.md view
@@ -4,7 +4,7 @@ Usage ----- -Cgrep 6.4.5 Usage: cgrep [OPTION] [PATTERN] files...+Cgrep 6.4.6 Usage: cgrep [OPTION] [PATTERN] files... cgrep [OPTIONS] [ITEM]
cgrep.cabal view
@@ -1,6 +1,6 @@ Name: cgrep Description: Cgrep: a context-aware grep for source codes-Version: 6.4.5+Version: 6.4.6 Synopsis: Command line tool Homepage: http://awgn.github.io/cgrep/ License: GPL-2@@ -42,6 +42,8 @@ stringsearch >=0.3, unordered-containers >=0.1, regex-posix >=0.90,+ either >= 4.0,+ mtl >= 2.0, unix >= 2.5 Ghc-options: -O2 -Wall -threaded Default-language: Haskell2010
src/CGrep/Lang.hs view
@@ -75,7 +75,7 @@ (Ruby, [Ext "rb", Ext "ruby"]), (Scala, [Ext "scala"]), (Tcl, [Ext "tcl", Ext "tk"]),- (Text, [Ext "txt", Ext "md", Name "README", Name "INSTALL"]),+ (Text, [Ext "txt", Ext "md", Ext "cabal", Ext "cfg", Name "README", Name "INSTALL"]), (Shell, [Ext "sh", Ext "bash", Ext "csh", Ext "tcsh", Ext "ksh", Ext "zsh"]), (Verilog, [Ext "v", Ext "vh", Ext "sv"]), (VHDL, [Ext "vhd", Ext "vhdl"]),
src/Config.hs view
@@ -31,7 +31,7 @@ cgreprc = "cgreprc" version :: String-version = "6.4.5"+version = "6.4.6" data Config = Config {
src/Main.hs view
@@ -31,6 +31,8 @@ import Control.Concurrent.STM.TChan import Control.Monad+import Control.Monad.Trans+import Control.Monad.Trans.Either import Control.Applicative import System.Console.CmdArgs@@ -84,7 +86,6 @@ else liftM C.words $ C.readFile f - main :: IO () main = do @@ -158,20 +159,19 @@ -- launch worker threads... - forM_ [1 .. jobs opts] $ \_ -> forkIO $- fix (\action -> do- f <- atomically $ readTChan in_chan- E.catch- (case f of- Nothing -> atomically $ writeTChan out_chan []- Just f' -> do- out <- let op = sanitizeOptions f' opts in- liftM (take (max_count opts)) $- cgrepDispatch op f' op patterns $ guard (f' /= "") >> Just f'- unless (null out) $ atomically $ writeTChan out_chan out- action )- (\e -> let msg = show (e :: SomeException) in hPutStrLn stderr (showFile opts (fromMaybe "<STDIN>" f) ++ ": exception: " ++ if length msg > 80 then take 80 msg ++ "..." else msg) >> action )- )+ forM_ [1 .. jobs opts] $ \_ -> forkIO $ do+ _ <- runEitherT $ forever $ do+ f <- lift $ atomically $ readTChan in_chan+ lift $ E.catch (case f of+ Nothing -> atomically $ writeTChan out_chan []+ Just x -> do+ out <- let op = sanitizeOptions x opts in+ liftM (take (max_count opts)) $ cgrepDispatch op x op patterns $ guard (x /= "") >> f+ unless (null out) $ atomically $ writeTChan out_chan out+ )+ (\e -> let msg = show (e :: SomeException) in hPutStrLn stderr (showFile opts (fromMaybe "<STDIN>" f) ++ ": exception: " ++ if length msg > 80 then take 80 msg ++ "..." else msg))+ when (isNothing f) $ left ()+ return () -- push the files to grep for...@@ -203,8 +203,7 @@ case () of _ | json opts -> when m $ putStrLn "," | otherwise -> return ()- xs <- prettyOutput opts out- mapM_ putStrLn xs+ prettyOutput opts out >>= mapM_ putStrLn action n True ) 0 False