Show More
@@ -329,6 +329,7 b' pub enum PatternFileWarning {' | |||
|
329 | 329 | pub fn parse_pattern_file_contents( |
|
330 | 330 | lines: &[u8], |
|
331 | 331 | file_path: &Path, |
|
332 | default_syntax_override: Option<&[u8]>, | |
|
332 | 333 | warn: bool, |
|
333 | 334 | ) -> Result<(Vec<IgnorePattern>, Vec<PatternFileWarning>), PatternError> { |
|
334 | 335 | let comment_regex = Regex::new(r"((?:^|[^\\])(?:\\\\)*)#.*").unwrap(); |
@@ -338,7 +339,8 b' pub fn parse_pattern_file_contents(' | |||
|
338 | 339 | let mut inputs: Vec<IgnorePattern> = vec![]; |
|
339 | 340 | let mut warnings: Vec<PatternFileWarning> = vec![]; |
|
340 | 341 | |
|
341 |
let mut current_syntax = |
|
|
342 | let mut current_syntax = | |
|
343 | default_syntax_override.unwrap_or(b"relre:".as_ref()); | |
|
342 | 344 | |
|
343 | 345 | for (line_number, mut line) in lines.split(|c| *c == b'\n').enumerate() { |
|
344 | 346 | let line_number = line_number + 1; |
@@ -413,7 +415,7 b' pub fn read_pattern_file(' | |||
|
413 | 415 | match std::fs::read(file_path) { |
|
414 | 416 | Ok(contents) => { |
|
415 | 417 | inspect_pattern_bytes(&contents); |
|
416 | parse_pattern_file_contents(&contents, file_path, warn) | |
|
418 | parse_pattern_file_contents(&contents, file_path, None, warn) | |
|
417 | 419 | } |
|
418 | 420 | Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(( |
|
419 | 421 | vec![], |
@@ -601,7 +603,12 b' mod tests {' | |||
|
601 | 603 | let lines = b"syntax: glob\n*.elc"; |
|
602 | 604 | |
|
603 | 605 | assert_eq!( |
|
604 |
parse_pattern_file_contents( |
|
|
606 | parse_pattern_file_contents( | |
|
607 | lines, | |
|
608 | Path::new("file_path"), | |
|
609 | None, | |
|
610 | false | |
|
611 | ) | |
|
605 | 612 |
|
|
606 | 613 |
|
|
607 | 614 | vec![IgnorePattern::new( |
@@ -614,14 +621,24 b' mod tests {' | |||
|
614 | 621 | let lines = b"syntax: include\nsyntax: glob"; |
|
615 | 622 | |
|
616 | 623 | assert_eq!( |
|
617 |
parse_pattern_file_contents( |
|
|
624 | parse_pattern_file_contents( | |
|
625 | lines, | |
|
626 | Path::new("file_path"), | |
|
627 | None, | |
|
628 | false | |
|
629 | ) | |
|
618 | 630 |
|
|
619 | 631 |
|
|
620 | 632 | vec![] |
|
621 | 633 | ); |
|
622 | 634 | let lines = b"glob:**.o"; |
|
623 | 635 | assert_eq!( |
|
624 |
parse_pattern_file_contents( |
|
|
636 | parse_pattern_file_contents( | |
|
637 | lines, | |
|
638 | Path::new("file_path"), | |
|
639 | None, | |
|
640 | false | |
|
641 | ) | |
|
625 | 642 |
|
|
626 | 643 |
|
|
627 | 644 | vec![IgnorePattern::new( |
General Comments 0
You need to be logged in to leave comments.
Login now