From 14a06b875746c6366c161a70f5eacbc6843d339e Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 14 Apr 2021 00:00:07 -0600 Subject: don't double-prune comments if there was an escaped # --- src/makefile/input.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/makefile/input.rs b/src/makefile/input.rs index e88314d..5a937f5 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -434,13 +434,11 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { Ok(x) => x, Err(err) => return Some((line_number, Err(err))), }; + let line_without_comments = COMMENT.replace(&line, "$1").replace(r"\#", "#"); + let line_without_comments = line_without_comments.trim_end(); // handle comments let line = if settings.strip_comments { - COMMENT - .replace(&line, "$1") - .replace(r"\#", "#") - .trim_end() - .to_owned() + line_without_comments.to_owned() } else { line }; @@ -470,7 +468,8 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { #[cfg(feature = "full")] { - let cond_line = ConditionalLine::from(&line, |t| self.expand_macros(t)); + let cond_line = + ConditionalLine::from(line_without_comments, |t| self.expand_macros(t)); let cond_line = match cond_line { Ok(x) => x, Err(err) => return Some((line_number, Err(err))), -- cgit v1.2.3