aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-14 00:00:07 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-14 00:00:07 -0600
commit14a06b875746c6366c161a70f5eacbc6843d339e (patch)
treeedecbc9bb72af97d490143d924a925dbda6342d5
parent82e10bfb3a080972ee3a1bb0e1f02a735a213b89 (diff)
downloadmakers-14a06b875746c6366c161a70f5eacbc6843d339e.tar.gz
makers-14a06b875746c6366c161a70f5eacbc6843d339e.zip
don't double-prune comments if there was an escaped #
-rw-r--r--src/makefile/input.rs11
1 files 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))),