aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile/input.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index 7c699f1..d6f6254 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -265,30 +265,30 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
return Some((line_number, Ok(line.join(escaped_newline_replacement))));
}
while let Some((line_number, line)) = self.lines_iter.next() {
- let mut line = match line {
+ let line = match line {
Ok(x) => x,
Err(err) => return Some((line_number, Err(err))),
};
+ // handle comments
+ lazy_static! {
+ static ref COMMENT: Regex = Regex::new("#.*$").unwrap();
+ }
+ let line = COMMENT.replace(&line, "").into_owned();
// handle escaped newlines
let mut line_pieces = vec![line];
while line_pieces.last().map_or(false, |p| p.ends_with('\\')) {
line_pieces.last_mut().map(|x| x.pop());
if let Some((n, x)) = self.lines_iter.next() {
- let x = match x {
+ let line = match x {
Ok(x) => x,
Err(err) => return Some((n, Err(err))),
};
- line_pieces.push(x.trim_start().to_string());
+ let line = COMMENT.replace(&line, "");
+ line_pieces.push(line.trim_start().to_string());
}
}
- line = line_pieces.join(escaped_newline_replacement);
-
- // handle comments
- lazy_static! {
- static ref COMMENT: Regex = Regex::new("#.*$").unwrap();
- }
- let line = COMMENT.replace(&line, "").into_owned();
+ let line = line_pieces.join(escaped_newline_replacement);
#[cfg(feature = "full")]
{
@@ -369,6 +369,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
}) {
let mut line = x?;
if !line.is_empty() {
+ assert!(line.starts_with('\t'));
line.remove(0);
}
if line.is_empty() {