From aa017eb4dc9f070c35711fdf908171938921c422 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Fri, 2 Apr 2021 20:11:50 -0600 Subject: ignore macro-expanded-to-empty lines --- src/makefile/mod.rs | 12 +++++++----- src/makefile/token.rs | 8 ++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index dfedd97..82d7d39 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -244,11 +244,13 @@ impl<'a> Makefile<'a> { LineType::Rule => self.read_rule(&line_tokens, line_number, &mut lines_iter)?, LineType::Macro => self.read_macro(&line_tokens, line_number)?, LineType::Unknown => { - bail!( - "error: line {}: unknown line \"{}\"", - line_number, - line_tokens - ); + if !line_tokens.is_empty() { + bail!( + "error: line {}: unknown line \"{}\"", + line_number, + line_tokens + ); + } } } } diff --git a/src/makefile/token.rs b/src/makefile/token.rs index 8bd0179..271580a 100644 --- a/src/makefile/token.rs +++ b/src/makefile/token.rs @@ -111,6 +111,14 @@ impl TokenString { *t = t.trim_end().into(); } } + + pub fn is_empty(&self) -> bool { + match self.0.get(0) { + None => true, + Some(Token::Text(t)) if t.is_empty() => true, + _ => false, + } + } } impl fmt::Display for TokenString { -- cgit v1.2.3