diff options
-rw-r--r-- | grep/src/search.rs | 19 | ||||
-rw-r--r-- | tests/tests.rs | 7 |
2 files changed, 25 insertions, 1 deletions
diff --git a/grep/src/search.rs b/grep/src/search.rs index 4e4c48e9..850c8d62 100644 --- a/grep/src/search.rs +++ b/grep/src/search.rs @@ -318,12 +318,29 @@ impl<'b, 's> Iterator for Iter<'b, 's> { fn has_uppercase_literal(expr: &Expr) -> bool { use syntax::Expr::*; + fn byte_is_upper(b: u8) -> bool { b'A' <= b && b <= b'Z' } match *expr { Literal { ref chars, casei } => { casei || chars.iter().any(|c| c.is_uppercase()) } LiteralBytes { ref bytes, casei } => { - casei || bytes.iter().any(|&b| b'A' <= b && b <= b'Z') + casei || bytes.iter().any(|&b| byte_is_upper(b)) + } + Class(ref ranges) => { + for r in ranges { + if r.start.is_uppercase() || r.end.is_uppercase() { + return true; + } + } + false + } + ClassBytes(ref ranges) => { + for r in ranges { + if byte_is_upper(r.start) || byte_is_upper(r.end) { + return true; + } + } + false } Group { ref e, .. } => has_uppercase_literal(e), Repeat { ref e, .. } => has_uppercase_literal(e), diff --git a/tests/tests.rs b/tests/tests.rs index 47169191..5c152b99 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -929,6 +929,13 @@ clean!(regression_228, "test", ".", |wd: WorkDir, mut cmd: Command| { wd.assert_err(&mut cmd); }); +// See: https://github.com/BurntSushi/ripgrep/issues/229 +clean!(regression_229, "[E]conomie", ".", |wd: WorkDir, mut cmd: Command| { + wd.create("foo", "economie"); + cmd.arg("-S"); + wd.assert_err(&mut cmd); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/7 sherlock!(feature_7, "-fpat", "sherlock", |wd: WorkDir, mut cmd: Command| { wd.create("pat", "Sherlock\nHolmes"); |