@@ -22,7 +22,6 @@ use std::panic;
2222use std:: path:: { Path , PathBuf } ;
2323
2424pub use gimli;
25- pub use glob;
2625pub use object;
2726pub use regex;
2827pub use wasmparser;
@@ -245,17 +244,18 @@ pub fn uname() -> String {
245244 output. stdout_utf8 ( )
246245}
247246
248- /// Inside a glob pattern of files (paths), read their contents and count the
247+ /// Search for all files in the current working directory with the extension `ext`,
248+ /// read their contents and count the
249249/// number of regex matches with a given expression (re).
250250#[ track_caller]
251- pub fn count_regex_matches_in_file_glob ( re : & str , paths : & str ) -> usize {
251+ pub fn count_regex_matches_in_files_with_extension ( re : & str , ext : & str ) -> usize {
252252 let re = regex:: Regex :: new ( re) . expect ( format ! ( "Regex expression {re} is not valid." ) . as_str ( ) ) ;
253- let paths = glob:: glob ( paths) . expect ( format ! ( "Glob expression {paths} is not valid." ) . as_str ( ) ) ;
254253 use io:: BufRead ;
255- paths
254+ fs_wrapper :: read_dir ( cwd ( ) )
256255 . filter_map ( |entry| entry. ok ( ) )
257- . filter ( |entry| entry. as_path ( ) . is_file ( ) )
258- . filter_map ( |path| fs:: File :: open ( & path) . ok ( ) )
256+ . filter ( |entry| entry. path ( ) . is_file ( ) )
257+ . filter ( |entry| entry. path ( ) . extension ( ) . unwrap ( ) == ext)
258+ . filter_map ( |entry| fs:: File :: open ( & entry. path ( ) ) . ok ( ) )
259259 . map ( |file| io:: BufReader :: new ( file) )
260260 . flat_map ( |reader| reader. lines ( ) . filter_map ( |entry| entry. ok ( ) ) )
261261 . filter ( |line| re. is_match ( line) )
0 commit comments