Show More
@@ -60,8 +60,8 b' fn glob_to_re(pat: &[u8]) -> Vec<u8> {' | |||
|
60 | 60 | match c { |
|
61 | 61 | b'*' => { |
|
62 | 62 | for (source, repl) in GLOB_REPLACEMENTS { |
|
63 |
if input. |
|
|
64 |
input = |
|
|
63 | if let Some(rest) = input.drop_prefix(source) { | |
|
64 | input = rest; | |
|
65 | 65 | res.extend(*repl); |
|
66 | 66 | break; |
|
67 | 67 | } |
@@ -269,8 +269,8 b' pub fn parse_pattern_file_contents(' | |||
|
269 | 269 | continue; |
|
270 | 270 | } |
|
271 | 271 | |
|
272 |
if line. |
|
|
273 |
let syntax = |
|
|
272 | if let Some(syntax) = line.drop_prefix(b"syntax:") { | |
|
273 | let syntax = syntax.trim(); | |
|
274 | 274 | |
|
275 | 275 | if let Some(rel_syntax) = SYNTAXES.get(syntax) { |
|
276 | 276 | current_syntax = rel_syntax; |
@@ -283,13 +283,14 b' pub fn parse_pattern_file_contents(' | |||
|
283 | 283 | let mut line_syntax: &[u8] = ¤t_syntax; |
|
284 | 284 | |
|
285 | 285 | for (s, rels) in SYNTAXES.iter() { |
|
286 |
if line. |
|
|
286 | if let Some(rest) = line.drop_prefix(rels) { | |
|
287 | 287 | line_syntax = rels; |
|
288 |
line = |
|
|
288 | line = rest; | |
|
289 | 289 | break; |
|
290 | } else if line.starts_with(&[s, b":".as_ref()].concat()) { | |
|
290 | } | |
|
291 | if let Some(rest) = line.drop_prefix(&[s, &b":"[..]].concat()) { | |
|
291 | 292 | line_syntax = rels; |
|
292 |
line = |
|
|
293 | line = rest; | |
|
293 | 294 | break; |
|
294 | 295 | } |
|
295 | 296 | } |
@@ -40,6 +40,7 b' pub trait SliceExt {' | |||
|
40 | 40 | fn trim_end(&self) -> &Self; |
|
41 | 41 | fn trim_start(&self) -> &Self; |
|
42 | 42 | fn trim(&self) -> &Self; |
|
43 | fn drop_prefix(&self, needle: &Self) -> Option<&Self>; | |
|
43 | 44 | } |
|
44 | 45 | |
|
45 | 46 | fn is_not_whitespace(c: &u8) -> bool { |
@@ -80,4 +81,12 b' impl SliceExt for [u8] {' | |||
|
80 | 81 | fn trim(&self) -> &[u8] { |
|
81 | 82 | self.trim_start().trim_end() |
|
82 | 83 | } |
|
84 | ||
|
85 | fn drop_prefix(&self, needle: &Self) -> Option<&Self> { | |
|
86 | if self.starts_with(needle) { | |
|
87 | Some(&self[needle.len()..]) | |
|
88 | } else { | |
|
89 | None | |
|
90 | } | |
|
91 | } | |
|
83 | 92 | } |
General Comments 0
You need to be logged in to leave comments.
Login now