aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile/input.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index 2b85376..3abdb8b 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -140,7 +140,6 @@ pub struct MakefileReader<'a, 'parent, R: BufRead> {
pub first_non_special_target: Option<String>,
args: &'a Args,
lines_iter: Peekable<LineNumbers<String, IoError, Lines<R>>>,
- pending_line: Option<(usize, Result<String>)>,
#[cfg(feature = "full")]
conditional_stack: Vec<ConditionalState>,
}
@@ -170,7 +169,6 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
lines_iter: source.lines().line_numbered().peekable(),
#[cfg(feature = "full")]
conditional_stack: Vec::new(),
- pending_line: None,
};
reader.read_all()?;
Ok(reader)
@@ -256,9 +254,6 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
&mut self,
escaped_newline_replacement: &'static str,
) -> Option<(usize, Result<String>)> {
- if let Some(x) = self.pending_line.take() {
- return Some(x);
- }
while let Some((line_number, line)) = self.lines_iter.next() {
let mut line = match line {
Ok(x) => x,
@@ -320,16 +315,16 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
None
}
+ /// Only applies the predicate to the next physical line in the file.
+ /// Doesn't apply the escaped newline replacement unless the predicate passes.
fn next_line_if(
&mut self,
escaped_newline_replacement: &'static str,
predicate: impl FnOnce(&(usize, Result<String>)) -> bool,
) -> Option<(usize, Result<String>)> {
- let pending_line = self.next_line(escaped_newline_replacement)?;
- if (predicate)(&pending_line) {
- Some(pending_line)
+ if predicate(self.lines_iter.peek()?) {
+ self.next_line(escaped_newline_replacement)
} else {
- self.pending_line = Some(pending_line);
None
}
}
@@ -544,6 +539,26 @@ mod test {
type R = Result<()>;
+ #[test]
+ fn multi_line_dependencies() -> R {
+ let file = "
+unrelated: example
+\tswag
+x = 3 4 \\
+\t\t5
+a: $(x) b \\
+\t\tc \\
+\t\td
+\tfoo";
+ let args = Args::empty();
+ let makefile = MakefileReader::read(&args, MacroSet::new(), Cursor::new(file))?.finish();
+ assert_eq!(
+ makefile.targets["a"].prerequisites,
+ vec!["3", "4", "5", "b", "c", "d"]
+ );
+ Ok(())
+ }
+
#[cfg(feature = "full")]
#[test]
fn basic_conditionals() -> R {