cgrep 6.4.7 → 6.4.8
raw patch · 4 files changed
+21/−18 lines, 4 files
Files
- README.md +1/−1
- cgrep.cabal +1/−1
- src/Config.hs +1/−1
- src/Main.hs +18/−15
README.md view
@@ -4,7 +4,7 @@ Usage ----- -Cgrep 6.4.7 Usage: cgrep [OPTION] [PATTERN] files...+Cgrep 6.4.8 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.7+Version: 6.4.8 Synopsis: Command line tool Homepage: http://awgn.github.io/cgrep/ License: GPL-2
src/Config.hs view
@@ -31,7 +31,7 @@ cgreprc = "cgreprc" version :: String-version = "6.4.7"+version = "6.4.8" data Config = Config {
src/Main.hs view
@@ -60,22 +60,25 @@ putRecursiveContents :: Options -> TChan (Maybe FilePath) -> FilePath -> [Lang] -> [String] -> Set.Set FilePath -> IO () putRecursiveContents opts inchan topdir langs prunedir visited = do dir <- doesDirectoryExist topdir- if dir then do+ if dir+ then do names <- liftM (filter (`notElem` [".", ".."])) $ getDirectoryContents topdir- forM_ names $ \n -> do- let path = topdir </> n- let filename = takeFileName path- cpath <- canonicalizePath path- status <- getFileStatus path- lstatus <- getSymbolicLinkStatus path- unless (cpath `Set.member` visited) $- if isDirectory status && (not (isSymbolicLink lstatus) || deference_recursive opts)- then unless (filename `elem` prunedir) $- putRecursiveContents opts inchan path langs prunedir (Set.insert cpath visited)- else case getLang opts filename >>= (\f -> f `elemIndex` langs <|> toMaybe 0 (null langs) ) of- Nothing -> return ()- _ -> atomically $ writeTChan inchan (Just path)- else atomically $ writeTChan inchan (Just topdir)+ forM_ names $ \n -> E.catch ( do+ let path = topdir </> n+ let filename = takeFileName path+ cpath <- canonicalizePath path+ status <- getFileStatus path+ lstatus <- getSymbolicLinkStatus path+ unless (cpath `Set.member` visited) $+ if isDirectory status && (not (isSymbolicLink lstatus) || deference_recursive opts)+ then unless (filename `elem` prunedir) $+ putRecursiveContents opts inchan path langs prunedir (Set.insert cpath visited)+ else case getLang opts filename >>= (\f -> f `elemIndex` langs <|> toMaybe 0 (null langs) ) of+ Nothing -> return ()+ _ -> atomically $ writeTChan inchan (Just path)+ )+ (\e -> let msg = show (e :: SomeException) in hPutStrLn stderr ("cgrep: " ++ msg))+ else atomically $ writeTChan inchan (Just topdir) -- read patterns from file