packages feed

cgrep 6.6.17 → 6.6.20

raw patch · 6 files changed

+27/−15 lines, 6 files

Files

README.md view
@@ -7,7 +7,7 @@ Usage ----- -Cgrep 6.6.17. Usage: cgrep [OPTION] [PATTERN] files...+Cgrep 6.6.20. 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.6.17+Version:             6.6.20 Synopsis:            Command line tool Homepage:            http://awgn.github.io/cgrep/ License:             GPL-2
src/CGrep/Filter.hs view
@@ -225,6 +225,7 @@     ,   (VHDL,       mkContextFilterFun [("--", "\n")] [("\"", "\"")] )     ,   (Verilog,    mkContextFilterFun [("/*", "*/"), ("//", "\n")]  [("\"", "\"")] )     ,   (Vim,        mkContextFilterFun [("\"", "\n")] [("'", "'")] )+    ,   (Yaml,       mkContextFilterFun [("#", "\n")]  [("\"", "\"")] )     ]  
src/CGrep/Lang.hs view
@@ -31,7 +31,7 @@ data Lang = Assembly | Awk  | C | CMake | Cabal | Chapel | Clojure | Coffee | Conf | Cpp  | Csharp | Css |             D | Elixir | Erlang | Fortran | Fsharp | Go | Haskell | Html | Idris | Java | Javascript | Latex |             Lua | Make | OCaml | ObjectiveC | PHP | Perl | Python | Ruby | Scala | Shell | Tcl |-            Text | VHDL | Verilog | Vim+            Text | VHDL | Verilog | Vim | Yaml                 deriving (Read, Show, Eq, Ord, Bounded)  @@ -52,7 +52,7 @@ langMap = Map.fromList     [  (Assembly,  [Ext "s", Ext "S"])     ,  (Awk,       [Ext "awk", Ext "mawk", Ext "gawk"])-    ,  (C,         [Ext "c", Ext "C"])+    ,  (C,         [Ext "c", Ext "C", Ext "inc"])     ,  (CMake,     [Name "CMakeLists.txt", Ext "cmake"])     ,  (Cabal,     [Ext "cabal"])     ,  (Chapel,    [Ext "chpl"])@@ -93,6 +93,7 @@     ,  (VHDL,      [Ext "vhd", Ext "vhdl"])     ,  (Verilog,   [Ext "v", Ext "vh", Ext "sv"])     ,  (Vim,       [Ext "vim"])+    ,  (Yaml,      [Ext "yaml", Ext "yml"])     ]  
src/CGrep/Output.hs view
@@ -135,14 +135,21 @@     case () of         _ |  Options{ no_filename = False, no_numbers = False , count = False } <- opt                 -> return $ map (\out -> concat $ [showFile conf, showSep ":", showLineCol, showSep ":", showTokens, showLine conf] <*> [opt] <*> [out]) xs+           |  Options{ no_filename = False, no_numbers = True  , count = False } <- opt                 -> return $ map (\out -> concat $ [showFile conf, showSep ":", showTokens,  showLine conf] <*> [opt] <*> [out] ) xs+           |  Options{ no_filename = True , no_numbers = False , count = False } <- opt                 -> return $ map (\out -> concat $ [showLineCol, showSep ":",  showTokens, showLine conf] <*> [opt] <*> [out] ) xs+           |  Options{ no_filename = True , no_numbers = True  , count = False } <- opt                 -> return $ map (\out -> concat $ [showTokens, showLine conf] <*> [opt] <*>  [out]) xs++          |  Options{ no_filename = False, count = True } <- opt -> do let gs = groupBy (\(Output f1 _ _ _) (Output f2 _ _ _) -> f1 == f2) xs+                                                                       return $ map (\ys@(y:_) -> showFile conf opt y ++ ":" ++ show (length ys)) gs+           |  Options{ count = True } <- opt -> do let gs = groupBy (\(Output f1 _ _ _) (Output f2 _ _ _) -> f1 == f2) xs-                                                  return $ map (\ys@(y:_) -> showFile conf opt y ++ ":" ++ show (length ys)) gs+                                                  return $ map (\ys -> show (length ys)) gs           |  otherwise -> undefined  @@ -242,7 +249,7 @@ showLineCol :: Options -> Output -> String showLineCol Options{no_numbers = True } _ = "" showLineCol Options{no_numbers = False, no_column = True  } (Output _ n _ _)  = show n-showLineCol Options{no_numbers = False, no_column = False } (Output _ n _ []) = show n +showLineCol Options{no_numbers = False, no_column = False } (Output _ n _ []) = show n showLineCol Options{no_numbers = False, no_column = False } (Output _ n _ ts) = show n ++ ":" ++ show ((+1) . fst . head $ ts)  
src/Main.hs view
@@ -39,7 +39,7 @@  import Control.Monad import Control.Monad.Trans-import Control.Monad.Trans.Either+import Control.Monad.Trans.Except import Control.Monad.Trans.Reader import Control.Applicative @@ -144,17 +144,20 @@     -- launch worker threads...      forM_ [1 .. jobs opts] $ \_ -> liftIO . forkIO $-        void $ runEitherT $ forever $ do+        void $ runExceptT . forever $ do             fs <- lift $ atomically $ readTChan in_chan             lift $ E.catch (case fs of                     [] -> atomically $ writeTChan out_chan []-                    xs -> void ((if asynch opts then flip mapConcurrently-                                                else forM) xs $ \x -> do-                                                    out <- fmap (take (max_count opts)) (runReaderT (runCgrep x patterns) (conf,sanitizeOptions x opts))-                                                    unless (null out) $ atomically $ writeTChan out_chan out)-                   )-                   (\e -> let msg = show (e :: SomeException) in hPutStrLn stderr (showFileName conf opts (getTargetName (head fs)) ++ ": exception: " ++ if length msg > 80 then take 80 msg ++ "..." else msg))-            when (null fs) $ left ()+                    xs -> void $ (if asynch opts then flip mapConcurrently+                                                 else forM) xs $ \x -> do+                            out <- fmap (take (max_count opts)) (runReaderT (runCgrep x patterns) (conf,sanitizeOptions x opts))+                            unless (null out) $ atomically $ writeTChan out_chan out)+                   (\e -> let msg = show (e :: SomeException) in+                        hPutStrLn stderr (showFileName conf opts (getTargetName (head fs))+                            ++ ": exception: " ++ if length msg > 80+                                                    then take 80 msg ++ "..."+                                                    else msg))+            when (null fs) $ throwE ()       -- push the files to grep for...