Show More
@@ -1,9 +1,9 b'' | |||||
1 | use crate::{ |
|
1 | use crate::{ | |
2 |
utils::{files::get_path_from_bytes, |
|
2 | utils::{files::get_path_from_bytes, SliceExt}, | |
3 | LineNumber, PatternError, PatternFileError, |
|
3 | LineNumber, PatternError, PatternFileError, | |
4 | }; |
|
4 | }; | |
5 | use lazy_static::lazy_static; |
|
5 | use lazy_static::lazy_static; | |
6 | use regex::bytes::Regex; |
|
6 | use regex::bytes::{NoExpand, Regex}; | |
7 | use std::collections::HashMap; |
|
7 | use std::collections::HashMap; | |
8 | use std::fs::File; |
|
8 | use std::fs::File; | |
9 | use std::io::Read; |
|
9 | use std::io::Read; | |
@@ -235,6 +235,7 b' pub fn parse_pattern_file_contents(' | |||||
235 | warn: bool, |
|
235 | warn: bool, | |
236 | ) -> (Vec<PatternTuple>, Vec<WarningTuple>) { |
|
236 | ) -> (Vec<PatternTuple>, Vec<WarningTuple>) { | |
237 | let comment_regex = Regex::new(r"((?:^|[^\\])(?:\\\\)*)#.*").unwrap(); |
|
237 | let comment_regex = Regex::new(r"((?:^|[^\\])(?:\\\\)*)#.*").unwrap(); | |
|
238 | let comment_escape_regex = Regex::new(r"\\#").unwrap(); | |||
238 | let mut inputs: Vec<PatternTuple> = vec![]; |
|
239 | let mut inputs: Vec<PatternTuple> = vec![]; | |
239 | let mut warnings: Vec<WarningTuple> = vec![]; |
|
240 | let mut warnings: Vec<WarningTuple> = vec![]; | |
240 |
|
241 | |||
@@ -243,12 +244,13 b' pub fn parse_pattern_file_contents(' | |||||
243 | for (line_number, mut line) in lines.split(|c| *c == b'\n').enumerate() { |
|
244 | for (line_number, mut line) in lines.split(|c| *c == b'\n').enumerate() { | |
244 | let line_number = line_number + 1; |
|
245 | let line_number = line_number + 1; | |
245 |
|
246 | |||
|
247 | let line_buf; | |||
246 | if line.contains(&b'#') { |
|
248 | if line.contains(&b'#') { | |
247 | if let Some(cap) = comment_regex.captures(line) { |
|
249 | if let Some(cap) = comment_regex.captures(line) { | |
248 | line = &line[..cap.get(1).unwrap().end()] |
|
250 | line = &line[..cap.get(1).unwrap().end()] | |
249 | } |
|
251 | } | |
250 | let mut line = line.to_owned(); |
|
252 | line_buf = comment_escape_regex.replace_all(line, NoExpand(b"#")); | |
251 | replace_slice(&mut line, br"\#", b"#"); |
|
253 | line = &line_buf; | |
252 | } |
|
254 | } | |
253 |
|
255 | |||
254 | let mut line = line.trim_end(); |
|
256 | let mut line = line.trim_end(); |
General Comments 0
You need to be logged in to leave comments.
Login now