grep-0.2.8/.cargo_vcs_info.json0000644000000001120000000000100117720ustar { "git": { "sha1": "1d53ed2744c246549f4be349310cb5a57c382d27" } } grep-0.2.8/COPYING000064400000000000000000000001760072674642500116570ustar 00000000000000This project is dual-licensed under the Unlicense and MIT licenses. You may use this code under the terms of either license. grep-0.2.8/Cargo.lock0000644000000272200000000000100077560ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "aho-corasick" version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", "winapi", ] [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bstr" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "lazy_static", "memchr", "regex-automata", ] [[package]] name = "bytecount" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" [[package]] name = "cc" version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" dependencies = [ "jobserver", ] [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "encoding_rs" version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" dependencies = [ "cfg-if 1.0.0", "packed_simd_2", ] [[package]] name = "encoding_rs_io" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cc3c5651fb62ab8aa3103998dade57efdd028544bd300516baa31840c252a83" dependencies = [ "encoding_rs", ] [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "globset" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0fc1b9fa0e64ffb1aa5b95daa0f0f167734fd528b7c02eabc581d9d843649b1" dependencies = [ "aho-corasick", "bstr", "fnv", "log", "regex", ] [[package]] name = "grep" version = "0.2.8" dependencies = [ "grep-cli", "grep-matcher", "grep-pcre2", "grep-printer", "grep-regex", "grep-searcher", "termcolor", "walkdir", ] [[package]] name = "grep-cli" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dd110c34bb4460d0de5062413b773e385cbf8a85a63fc535590110a09e79e8a" dependencies = [ "atty", "bstr", "globset", "lazy_static", "log", "regex", "same-file", "termcolor", "winapi-util", ] [[package]] name = "grep-matcher" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d27563c33062cd33003b166ade2bb4fd82db1fd6a86db764dfdad132d46c1cc" dependencies = [ "memchr", ] [[package]] name = "grep-pcre2" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6ecedbb372bd549ae8db02418f82e87e38622844409b6cbcac47dbc95eede41" dependencies = [ "grep-matcher", "pcre2", ] [[package]] name = "grep-printer" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c271a24daedf5675b61a275a1d0af06e03312ab7856d15433ae6cde044dc72" dependencies = [ "base64", "bstr", "grep-matcher", "grep-searcher", "serde", "serde_json", "termcolor", ] [[package]] name = "grep-regex" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "121553c9768c363839b92fc2d7cdbbad44a3b70e8d6e7b1b72b05c977527bd06" dependencies = [ "aho-corasick", "bstr", "grep-matcher", "log", "regex", "regex-syntax", "thread_local", ] [[package]] name = "grep-searcher" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fbdbde90ba52adc240d2deef7b6ad1f99f53142d074b771fe9b7bede6c4c23d" dependencies = [ "bstr", "bytecount", "encoding_rs", "encoding_rs_io", "grep-matcher", "log", "memmap2", ] [[package]] name = "hermit-abi" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] name = "itoa" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jobserver" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" dependencies = [ "libc", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" [[package]] name = "libm" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "log" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "memchr" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memmap2" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20ff203f7bdc401350b1dbaa0355135777d25f41c0bbc601851bbd6cf61e8ff5" dependencies = [ "libc", ] [[package]] name = "once_cell" version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "packed_simd_2" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e64858a2d3733fdd61adfdd6da89aa202f7ff0e741d2fc7ed1e452ba9dc99d7" dependencies = [ "cfg-if 0.1.10", "libm", ] [[package]] name = "pcre2" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b30f2f69903b439dd9dc9e824119b82a55bf113b29af8d70948a03c1b11ab1" dependencies = [ "libc", "log", "pcre2-sys", "thread_local", ] [[package]] name = "pcre2-sys" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dec30e5e9ec37eb8fbf1dea5989bc957fd3df56fbee5061aa7b7a99dbb37b722" dependencies = [ "cc", "libc", "pkg-config", ] [[package]] name = "pkg-config" version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "proc-macro2" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ "unicode-xid", ] [[package]] name = "quote" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] [[package]] name = "regex" version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", ] [[package]] name = "serde" version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", "serde", ] [[package]] name = "syn" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] [[package]] name = "termcolor" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "thread_local" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ "once_cell", ] [[package]] name = "unicode-xid" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "walkdir" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", "winapi-util", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" grep-0.2.8/Cargo.toml0000644000000027000000000000100077750ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "grep" version = "0.2.8" authors = ["Andrew Gallant "] description = "Fast line oriented regex searching as a library.\n" homepage = "https://github.com/BurntSushi/ripgrep/tree/master/crates/grep" documentation = "https://docs.rs/grep" readme = "README.md" keywords = ["regex", "grep", "egrep", "search", "pattern"] license = "Unlicense/MIT" repository = "https://github.com/BurntSushi/ripgrep/tree/master/crates/grep" [dependencies.grep-cli] version = "0.1.6" [dependencies.grep-matcher] version = "0.1.5" [dependencies.grep-pcre2] version = "0.1.5" optional = true [dependencies.grep-printer] version = "0.1.6" [dependencies.grep-regex] version = "0.1.9" [dependencies.grep-searcher] version = "0.1.8" [dev-dependencies.termcolor] version = "1.0.4" [dev-dependencies.walkdir] version = "2.2.7" [features] avx-accel = [] pcre2 = ["grep-pcre2"] simd-accel = ["grep-searcher/simd-accel"] grep-0.2.8/Cargo.toml.orig000064400000000000000000000020620072674642500135070ustar 00000000000000[package] name = "grep" version = "0.2.8" #:version authors = ["Andrew Gallant "] description = """ Fast line oriented regex searching as a library. """ documentation = "https://docs.rs/grep" homepage = "https://github.com/BurntSushi/ripgrep/tree/master/crates/grep" repository = "https://github.com/BurntSushi/ripgrep/tree/master/crates/grep" readme = "README.md" keywords = ["regex", "grep", "egrep", "search", "pattern"] license = "Unlicense/MIT" edition = "2018" [dependencies] grep-cli = { version = "0.1.6", path = "../cli" } grep-matcher = { version = "0.1.5", path = "../matcher" } grep-pcre2 = { version = "0.1.5", path = "../pcre2", optional = true } grep-printer = { version = "0.1.6", path = "../printer" } grep-regex = { version = "0.1.9", path = "../regex" } grep-searcher = { version = "0.1.8", path = "../searcher" } [dev-dependencies] termcolor = "1.0.4" walkdir = "2.2.7" [features] simd-accel = ["grep-searcher/simd-accel"] pcre2 = ["grep-pcre2"] # This feature is DEPRECATED. Runtime dispatch is used for SIMD now. avx-accel = [] grep-0.2.8/LICENSE-MIT000064400000000000000000000020710072674642500122540ustar 00000000000000The MIT License (MIT) Copyright (c) 2015 Andrew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. grep-0.2.8/README.md000064400000000000000000000015540072674642500121040ustar 00000000000000grep ---- ripgrep, as a library. [![Build status](https://github.com/BurntSushi/ripgrep/workflows/ci/badge.svg)](https://github.com/BurntSushi/ripgrep/actions) [![](https://img.shields.io/crates/v/grep.svg)](https://crates.io/crates/grep) Dual-licensed under MIT or the [UNLICENSE](https://unlicense.org/). ### Documentation [https://docs.rs/grep](https://docs.rs/grep) NOTE: This crate isn't ready for wide use yet. Ambitious individuals can probably piece together the parts, but there is no high level documentation describing how all of the pieces fit together. ### Usage Add this to your `Cargo.toml`: ```toml [dependencies] grep = "0.2" ``` ### Features This crate provides a `pcre2` feature (disabled by default) which, when enabled, re-exports the `grep-pcre2` crate as an alternative `Matcher` implementation to the standard `grep-regex` implementation. grep-0.2.8/UNLICENSE000064400000000000000000000022730072674642500120740ustar 00000000000000This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to grep-0.2.8/examples/simplegrep.rs000064400000000000000000000036400072674642500151560ustar 00000000000000use std::env; use std::error::Error; use std::ffi::OsString; use std::process; use grep::cli; use grep::printer::{ColorSpecs, StandardBuilder}; use grep::regex::RegexMatcher; use grep::searcher::{BinaryDetection, SearcherBuilder}; use termcolor::ColorChoice; use walkdir::WalkDir; fn main() { if let Err(err) = try_main() { eprintln!("{}", err); process::exit(1); } } fn try_main() -> Result<(), Box> { let mut args: Vec = env::args_os().collect(); if args.len() < 2 { return Err("Usage: simplegrep [ ...]".into()); } if args.len() == 2 { args.push(OsString::from("./")); } search(cli::pattern_from_os(&args[1])?, &args[2..]) } fn search(pattern: &str, paths: &[OsString]) -> Result<(), Box> { let matcher = RegexMatcher::new_line_matcher(&pattern)?; let mut searcher = SearcherBuilder::new() .binary_detection(BinaryDetection::quit(b'\x00')) .line_number(false) .build(); let mut printer = StandardBuilder::new() .color_specs(ColorSpecs::default_with_color()) .build(cli::stdout(if cli::is_tty_stdout() { ColorChoice::Auto } else { ColorChoice::Never })); for path in paths { for result in WalkDir::new(path) { let dent = match result { Ok(dent) => dent, Err(err) => { eprintln!("{}", err); continue; } }; if !dent.file_type().is_file() { continue; } let result = searcher.search_path( &matcher, dent.path(), printer.sink_with_path(&matcher, dent.path()), ); if let Err(err) = result { eprintln!("{}: {}", dent.path().display(), err); } } } Ok(()) } grep-0.2.8/src/lib.rs000064400000000000000000000012500072674642500125210ustar 00000000000000/*! ripgrep, as a library. This library is intended to provide a high level facade to the crates that make up ripgrep's core searching routines. However, there is no high level documentation available yet guiding users on how to fit all of the pieces together. Every public API item in the constituent crates is documented, but examples are sparse. A cookbook and a guide are planned. */ #![deny(missing_docs)] pub extern crate grep_cli as cli; pub extern crate grep_matcher as matcher; #[cfg(feature = "pcre2")] pub extern crate grep_pcre2 as pcre2; pub extern crate grep_printer as printer; pub extern crate grep_regex as regex; pub extern crate grep_searcher as searcher;