History

frame for character classes (#301)

Sebastian Thiel committed 4 years ago

Commit 6b8d0d21 parent 3afe2d22 files · +43 −3Browse files

Unified · Split

2 files
  1. git-glob/src/wildmatch.rs +43 −2
  2. git-glob/tests/matching/mod.rs +0 −1
git-glob/src/wildmatch.rs+43−2
@@ -27,6 +27,7 @@ pub(crate) mod function { · 26 unmodified lines
27 const SLASH: u8 = b'/';27 const SLASH: u8 = b'/';
28 const BRACKET_OPEN: u8 = b'[';28 const BRACKET_OPEN: u8 = b'[';
29 const BRACKET_CLOSE: u8 = b']';29 const BRACKET_CLOSE: u8 = b']';
30 const COLON: u8 = b':';
30 31
31 const NEGATE_CLASS: u8 = b'!';32 const NEGATE_CLASS: u8 = b'!';
32 33
@@ -175,7 +176,7 @@ pub(crate) mod function { · 142 unmodified lines
175 loop {176 loop {
176 match next {177 match next {
177 None => return AbortAll,178 None => return AbortAll,
178 Some((_p_idx, mut p_ch)) => match p_ch {179 Some((p_idx, mut p_ch)) => match p_ch {
179 BACKSLASH => match p.next() {180 BACKSLASH => match p.next() {
180 Some((_, p_ch)) => {181 Some((_, p_ch)) => {
181 if p_ch == t_ch {182 if p_ch == t_ch {
@@ -211,7 +212,47 @@ pub(crate) mod function { · 29 unmodified lines
211 }212 }
212 prev_p_ch = 0;213 prev_p_ch = 0;
213 }214 }
214 BRACKET_OPEN => todo!("class open"),215 BRACKET_OPEN if matches!(p.peek(), Some((_, COLON))) => {
216 p.next();
217 while p.peek().map_or(false, |t| t.1 != BRACKET_CLOSE) {
218 p.next();
219 }
220 let closing_bracket_idx = match p.next() {
221 Some((idx, _)) => idx,
222 None => return AbortAll,
223 };
224 const BRACKET__COLON__BRACKET: usize = 3;
225 if closing_bracket_idx - p_idx < BRACKET__COLON__BRACKET
226 || pattern[closing_bracket_idx - 1] != COLON
227 {
228 if t_ch == BRACKET_OPEN {
229 matched = true
230 }
231 p = pattern[p_idx + 1..]
232 .iter()
233 .map(possibly_lowercase)
234 .enumerate()
235 .peekable();
236 } else {
237 let class = &pattern.as_ref()[p_idx + 2..closing_bracket_idx - 1];
238 match class {
239 b"alnum" => todo!("alnum"),
240 b"alpha" => todo!("alpha"),
241 b"blank" => todo!("blank"),
242 b"cntrl" => todo!("cntrl"),
243 b"digit" => todo!("digit"),
244 b"graph" => todo!("graph"),
245 b"lower" => todo!("lower"),
246 b"print" => todo!("print"),
247 b"punct" => todo!("punct"),
248 b"space" => todo!("space"),
249 b"upper" => todo!("upper"),
250 b"xdigit" => todo!("xdigit"),
251 _ => return AbortAll,
252 };
253 prev_p_ch = 0;
254 }
255 }
215 _ => {256 _ => {
216 prev_p_ch = p_ch;257 prev_p_ch = p_ch;
217 if p_ch == t_ch {258 if p_ch == t_ch {
git-glob/tests/matching/mod.rs+0−1
@@ -42,7 +42,6 @@ impl<'a> Baseline<'a> { · 41 unmodified lines
42}42}
43 43
44#[test]44#[test]
45#[ignore]
46fn compare_baseline_with_ours() {45fn compare_baseline_with_ours() {
47 let dir = git_testtools::scripted_fixture_repo_read_only("make_baseline.sh").unwrap();46 let dir = git_testtools::scripted_fixture_repo_read_only("make_baseline.sh").unwrap();
48 let (mut total_matches, mut total_correct, mut panics) = (0, 0, 0);47 let (mut total_matches, mut total_correct, mut panics) = (0, 0, 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t