From 28a7665f7aa08ffac2e3855efc8789abe675a18d Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 13 Mar 2018 22:45:27 -0700 Subject: [PATCH] Rebuild with new regex crates --- 0001-deps-update-regex-crate.patch | 35 +++++++++ 0001-grep-upgrade-to-regex-syntax-0.5.patch | 83 +++++++++++++++++++++ rust-ripgrep.spec | 9 ++- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 0001-deps-update-regex-crate.patch create mode 100644 0001-grep-upgrade-to-regex-syntax-0.5.patch diff --git a/0001-deps-update-regex-crate.patch b/0001-deps-update-regex-crate.patch new file mode 100644 index 0000000..310ba0e --- /dev/null +++ b/0001-deps-update-regex-crate.patch @@ -0,0 +1,35 @@ +From 1f70e9187ceca65e7196f65e8cad1cba65efb47c Mon Sep 17 00:00:00 2001 +From: Andrew Gallant +Date: Sat, 10 Mar 2018 14:02:06 -0500 +Subject: [PATCH] deps: update regex crate + +This update brings with it a new feature of the regex crate which will +now use SIMD optimizations automatically at runtime with no necessary +compile time flags. All that's needed is to enable the `unstable` feature. + +Other crates, such as bytecount and encoding_rs, are still using the +old-style SIMD support, so we leave the simd-accel and avx-accel features. +However, the binaries we distribute on Github no longer have those +features enabled, which makes them truly portable. + +Fixes #135 +--- + src/args.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/args.rs b/src/args.rs +index d2077d678b9d..c7b31dd3646e 100644 +--- a/src/args.rs ++++ b/src/args.rs +@@ -599,7 +599,7 @@ impl<'a> ArgMatches<'a> { + // This would normally just be an empty string, which works on its + // own, but if the patterns are joined in a set of alternations, then + // you wind up with `foo|`, which is invalid. +- self.word_pattern("z{0}".to_string()) ++ self.word_pattern("(?:z{0})*".to_string()) + } + + /// Returns true if and only if file names containing each match should +-- +2.14.3 + diff --git a/0001-grep-upgrade-to-regex-syntax-0.5.patch b/0001-grep-upgrade-to-regex-syntax-0.5.patch new file mode 100644 index 0000000..532e89d --- /dev/null +++ b/0001-grep-upgrade-to-regex-syntax-0.5.patch @@ -0,0 +1,83 @@ +From cd08707c7c82058559bd5557efb3c1d0379dbf1d Mon Sep 17 00:00:00 2001 +From: Andrew Gallant +Date: Tue, 13 Mar 2018 20:38:50 -0400 +Subject: [PATCH] grep: upgrade to regex-syntax 0.5 + +This update brings with it many bug fixes: + + * Better error messages are printed overall. We also include + explicit call out for unsupported features like backreferences + and look-around. + * Regexes like `\s*{` no longer emit incomprehensible errors. + * Unicode escape sequences, such as `\u{..}` are now supported. + +For the most part, this upgrade was done in a straight-forward way. We +resist the urge to refactor the `grep` crate, in anticipation of it +being rewritten anyway. + +Note that we removed the `--fixed-strings` suggestion whenever a regex +syntax error occurs. In practice, I've found that it results in a lot of +false positives, and I believe that its use is not as paramount now that +regex parse errors are much more readable. + +Closes #268, Closes #395, Closes #702, Closes #853 +--- + src/args.rs | 13 ++----------- + tests/tests.rs | 10 ---------- + 2 files changed, 2 insertions(+), 21 deletions(-) + +diff --git a/src/args.rs b/src/args.rs +index c7b31dd3646e..2bbabf1a3b76 100644 +--- a/src/args.rs ++++ b/src/args.rs +@@ -9,7 +9,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; + + use clap; + use encoding_rs::Encoding; +-use grep::{Grep, GrepBuilder, Error as GrepError}; ++use grep::{Grep, GrepBuilder}; + use log; + use num_cpus; + use regex; +@@ -882,16 +882,7 @@ impl<'a> ArgMatches<'a> { + if let Some(limit) = self.regex_size_limit()? { + gb = gb.size_limit(limit); + } +- gb.build().map_err(|err| { +- match err { +- GrepError::Regex(err) => { +- let s = format!("{}\n(Hint: Try the --fixed-strings flag \ +- to search for a literal string.)", err.to_string()); +- From::from(s) +- }, +- err => From::from(err) +- } +- }) ++ Ok(gb.build()?) + } + + /// Builds the set of glob overrides from the command line flags. +diff --git a/tests/tests.rs b/tests/tests.rs +index 8cb871843851..855f2484ddd3 100644 +--- a/tests/tests.rs ++++ b/tests/tests.rs +@@ -1687,16 +1687,6 @@ sherlock!(feature_419_zero_as_shortcut_for_null, "Sherlock", ".", + assert_eq!(lines, "sherlock\x002\n"); + }); + +-// See: https://github.com/BurntSushi/ripgrep/issues/709 +-clean!(suggest_fixed_strings_for_invalid_regex, "foo(", ".", +-|wd: WorkDir, mut cmd: Command| { +- wd.assert_non_empty_stderr(&mut cmd); +- +- let output = cmd.output().unwrap(); +- let err = String::from_utf8_lossy(&output.stderr); +- assert_eq!(err.contains("--fixed-strings"), true); +-}); +- + #[test] + fn compressed_gzip() { + if !cmd_exists("gzip") { +-- +2.14.3 + diff --git a/rust-ripgrep.spec b/rust-ripgrep.spec index 17340c6..6db1037 100644 --- a/rust-ripgrep.spec +++ b/rust-ripgrep.spec @@ -5,7 +5,7 @@ Name: rust-%{crate} Version: 0.8.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Line oriented search tool using Rust's regex library License: Unlicense or MIT @@ -15,6 +15,10 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{ # * No simd # * No windows Patch0: ripgrep-0.8.1-fix-metadata.diff +# https://github.com/BurntSushi/ripgrep/pull/857 +Patch1: 0001-deps-update-regex-crate.patch +# https://github.com/BurntSushi/ripgrep/pull/858 +Patch2: 0001-grep-upgrade-to-regex-syntax-0.5.patch ExclusiveArch: %{rust_arches} @@ -90,6 +94,9 @@ the raw performance of grep with the usability of the silver searcher. %{_datadir}/zsh/site-functions/_rg %changelog +* Wed Mar 14 2018 Josh Stone - 0.8.1-3 +- Rebuild with new regex crates + * Fri Feb 23 2018 Igor Gnatenko - 0.8.1-2 - Restore spec