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