packages feed

cgrep 6.4.9 → 6.4.10

raw patch · 5 files changed

+31/−26 lines, 5 files

Files

README.md view
@@ -4,7 +4,7 @@ Usage ----- -Cgrep 6.4.9 Usage: cgrep [OPTION] [PATTERN] files...+Cgrep 6.4.10 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.9+Version:             6.4.10 Synopsis:            Command line tool Homepage:            http://awgn.github.io/cgrep/ License:             GPL-2
src/CGrep/Common.hs view
@@ -95,12 +95,12 @@   unquotes :: String -> String-unquotes []     = []-unquotes (x:[]) = [x]+unquotes []   = []+unquotes [x]  = [x] unquotes y@(x:xs)     | x == '"' || x == '\'' =  if x == last xs then init xs                                                else y-   | otherwise = y+    | otherwise = y   
src/Config.hs view
@@ -31,16 +31,19 @@ cgreprc = "cgreprc"  version :: String-version = "6.4.9"+version = "6.4.10" + data Config = Config               {-                    languages :: [Lang],-                    pruneDirs :: [String]+                    configLanguages  :: [Lang],+                    configPruneDirs  :: [String],+                    configColor      :: Bool                } deriving (Show, Read)  + getConfig :: IO Config getConfig = do     home <- getHomeDirectory@@ -49,7 +52,7 @@      if isJust conf then readFile (fromJust conf) >>= \xs ->                         return (prettyRead (dropComments xs) "Config error" :: Config)-                   else return $ Config [] []+                   else return $ Config [] [] False      where dropComments :: String -> String           dropComments = unlines . map (takeWhile $ not .(== '#')) . lines
src/Main.hs view
@@ -92,13 +92,20 @@ main :: IO () main = do -    -- read command-line options+    -- check whether is a terminal device -    opts  <- cmdArgsRun options+    isTermIn  <- hIsTerminalDevice stdin+    isTermOut <- hIsTerminalDevice stdout -    putStrLevel1 (debug opts) $ "Cgrep " ++ version ++ "!"-    putStrLevel1 (debug opts) $ "options   : " ++ show opts+    -- read Cgrep config options +    conf  <- getConfig++    -- read command-line options++    opts  <- if isTermOut then (\o@Options{color = c} -> o { color = c || configColor conf}) <$> cmdArgsRun options+                          else (\x -> x {color = False}) <$>  cmdArgsRun options+     -- check for multiple backends...      when (length (catMaybes [@@ -118,10 +125,6 @@      when (null $ others opts) $ withArgs ["--help"] $ void (cmdArgsRun options) -    -- read Cgrep config options--    conf  <- getConfig-     -- load patterns:      patterns <- (if null $ file opts then return [C.pack $ head $ others opts]@@ -131,15 +134,11 @@                                 else ps  -    -- check whether is a terminal device--    isTerm <- hIsTerminalDevice stdin-     -- retrieve files to parse      let tailOpts = tail $ others opts -    let paths = if null $ file opts then if null tailOpts && isTerm then ["."] else tailOpts+    let paths = if null $ file opts then if null tailOpts && isTermIn then ["."] else tailOpts                                     else others opts      -- parse cmd line language list:@@ -148,12 +147,15 @@      -- language enabled: -    let lang_enabled = (if null l0 then languages conf else l0 `union` l1) \\ l2+    let lang_enabled = (if null l0 then configLanguages conf else l0 `union` l1) \\ l2 +    putStrLevel1 (debug opts) $ "Cgrep " ++ version ++ "!"+    putStrLevel1 (debug opts) $ "options   : " ++ show opts     putStrLevel1 (debug opts) $ "languages : " ++ show lang_enabled     putStrLevel1 (debug opts) $ "pattern   : " ++ show patterns     putStrLevel1 (debug opts) $ "files     : " ++ show paths-    putStrLevel1 (debug opts) $ "isTerm    : " ++ show isTerm+    putStrLevel1 (debug opts) $ "isTermIn  : " ++ show isTermIn+    putStrLevel1 (debug opts) $ "isTermOut : " ++ show isTermOut      -- create Transactional Chan and Vars... @@ -182,9 +184,9 @@     _ <- forkIO $ do          if recursive opts || deference_recursive opts-            then forM_ paths $ \p -> putRecursiveContents opts in_chan p lang_enabled (pruneDirs conf) (Set.singleton p)+            then forM_ paths $ \p -> putRecursiveContents opts in_chan p lang_enabled (configPruneDirs conf) (Set.singleton p)             else do-                files <- liftM (\l -> if null l && not isTerm then [""] else l) $ filterM doesFileExist paths+                files <- liftM (\l -> if null l && not isTermIn then [""] else l) $ filterM doesFileExist paths                 forM_ files (atomically . writeTChan in_chan . Just)          -- enqueue EOF messages: