Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/filepatterns.rs @ 42483:a4a468b00d44
rust-filepatterns: silence warning of non_upper_case_globals
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Jun 2019 10:35:53 +0900 |
parents | 48f1f864d928 |
children | 326fdce22fb2 |
comparison
equal
deleted
inserted
replaced
42482:cc4db4478467 | 42483:a4a468b00d44 |
---|---|
6 use std::vec::Vec; | 6 use std::vec::Vec; |
7 use utils::files::get_path_from_bytes; | 7 use utils::files::get_path_from_bytes; |
8 use utils::{replace_slice, SliceExt}; | 8 use utils::{replace_slice, SliceExt}; |
9 | 9 |
10 lazy_static! { | 10 lazy_static! { |
11 static ref reescape: Vec<Vec<u8>> = { | 11 static ref RE_ESCAPE: Vec<Vec<u8>> = { |
12 let mut v: Vec<Vec<u8>> = (0..=255).map(|byte| vec![byte]).collect(); | 12 let mut v: Vec<Vec<u8>> = (0..=255).map(|byte| vec![byte]).collect(); |
13 let to_escape = b"()[]{}?*+-|^$\\.&~# \t\n\r\x0b\x0c"; | 13 let to_escape = b"()[]{}?*+-|^$\\.&~# \t\n\r\x0b\x0c"; |
14 for byte in to_escape { | 14 for byte in to_escape { |
15 v[*byte as usize].insert(0, b'\\'); | 15 v[*byte as usize].insert(0, b'\\'); |
16 } | 16 } |
97 c | 97 c |
98 } else { | 98 } else { |
99 c | 99 c |
100 } | 100 } |
101 }; | 101 }; |
102 res.extend(&reescape[*c as usize]) | 102 res.extend(&RE_ESCAPE[*c as usize]) |
103 } | 103 } |
104 _ => res.extend(&reescape[*c as usize]), | 104 _ => res.extend(&RE_ESCAPE[*c as usize]), |
105 } | 105 } |
106 } | 106 } |
107 res | 107 res |
108 } | 108 } |
109 | 109 |
110 fn escape_pattern(pattern: &[u8]) -> Vec<u8> { | 110 fn escape_pattern(pattern: &[u8]) -> Vec<u8> { |
111 pattern | 111 pattern |
112 .iter() | 112 .iter() |
113 .flat_map(|c| reescape[*c as usize].clone()) | 113 .flat_map(|c| RE_ESCAPE[*c as usize].clone()) |
114 .collect() | 114 .collect() |
115 } | 115 } |
116 | 116 |
117 fn parse_pattern_syntax(kind: &[u8]) -> Result<PatternSyntax, PatternError> { | 117 fn parse_pattern_syntax(kind: &[u8]) -> Result<PatternSyntax, PatternError> { |
118 match kind { | 118 match kind { |