You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.4 KiB
67 lines
2.4 KiB
From 5616ca398ffa54643ae3c139518060d4523be687 Mon Sep 17 00:00:00 2001
|
|
From: Josh Stone <cuviper@gmail.com>
|
|
Date: Wed, 7 Mar 2018 21:48:02 -0800
|
|
Subject: [PATCH] Update to regex-syntax 0.5
|
|
|
|
The new regex 0.2.7 has updated to regex-syntax 0.5, so it seems prudent
|
|
to update fd's dependency too, if only to avoid duplication.
|
|
---
|
|
src/internal.rs | 28 +++++++++++++++++-----------
|
|
1 file changed, 17 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/src/internal.rs b/src/internal.rs
|
|
index fe9a43db5640..a2bb96a89772 100644
|
|
--- a/src/internal.rs
|
|
+++ b/src/internal.rs
|
|
@@ -15,7 +15,8 @@ use std::io::Write;
|
|
use exec::CommandTemplate;
|
|
use lscolors::LsColors;
|
|
use walk::FileType;
|
|
-use regex_syntax::{Expr, ExprBuilder};
|
|
+use regex_syntax::Parser;
|
|
+use regex_syntax::hir::Hir;
|
|
use regex::RegexSet;
|
|
|
|
/// Configuration options for *fd*.
|
|
@@ -83,22 +84,27 @@ pub fn error(message: &str) -> ! {
|
|
|
|
/// Determine if a regex pattern contains a literal uppercase character.
|
|
pub fn pattern_has_uppercase_char(pattern: &str) -> bool {
|
|
- ExprBuilder::new()
|
|
+ Parser::new()
|
|
.parse(pattern)
|
|
- .map(|expr| expr_has_uppercase_char(&expr))
|
|
+ .map(|hir| hir_has_uppercase_char(&hir))
|
|
.unwrap_or(false)
|
|
}
|
|
|
|
/// Determine if a regex expression contains a literal uppercase character.
|
|
-fn expr_has_uppercase_char(expr: &Expr) -> bool {
|
|
- match *expr {
|
|
- Expr::Literal { ref chars, .. } => chars.iter().any(|c| c.is_uppercase()),
|
|
- Expr::Class(ref ranges) => ranges
|
|
+fn hir_has_uppercase_char(hir: &Hir) -> bool {
|
|
+ use regex_syntax::hir::*;
|
|
+
|
|
+ match *hir.kind() {
|
|
+ HirKind::Literal(Literal::Unicode(c)) => c.is_uppercase(),
|
|
+ HirKind::Class(Class::Unicode(ref ranges)) => ranges
|
|
.iter()
|
|
- .any(|r| r.start.is_uppercase() || r.end.is_uppercase()),
|
|
- Expr::Group { ref e, .. } | Expr::Repeat { ref e, .. } => expr_has_uppercase_char(e),
|
|
- Expr::Concat(ref es) => es.iter().any(expr_has_uppercase_char),
|
|
- Expr::Alternate(ref es) => es.iter().any(expr_has_uppercase_char),
|
|
+ .any(|r| r.start().is_uppercase() || r.end().is_uppercase()),
|
|
+ HirKind::Group(Group { ref hir, .. }) | HirKind::Repetition(Repetition { ref hir, .. }) => {
|
|
+ hir_has_uppercase_char(hir)
|
|
+ }
|
|
+ HirKind::Concat(ref hirs) | HirKind::Alternation(ref hirs) => {
|
|
+ hirs.iter().any(hir_has_uppercase_char)
|
|
+ }
|
|
_ => false,
|
|
}
|
|
}
|
|
--
|
|
2.14.3
|
|
|