aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-03 19:03:13 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-03 19:03:13 -0600
commit05bbe1fdf143652ae62fcc1e121babb6ec76726b (patch)
tree04210a172cf528502652ff5e0f9472aa389d3eed /src
parent27abec50cbcc3e18b375bca050fc280cf089b55c (diff)
downloadmakers-05bbe1fdf143652ae62fcc1e121babb6ec76726b.tar.gz
makers-05bbe1fdf143652ae62fcc1e121babb6ec76726b.zip
do not infinitely recurse ever
Diffstat (limited to 'src')
-rw-r--r--src/makefile/mod.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs
index e004586..c81526b 100644
--- a/src/makefile/mod.rs
+++ b/src/makefile/mod.rs
@@ -5,7 +5,7 @@ use std::fmt;
use std::path::{Path, PathBuf};
use std::rc::Rc;
-use eyre::{eyre, Result};
+use eyre::{bail, eyre, Result};
use crate::args::Args;
@@ -36,6 +36,7 @@ pub struct Makefile<'a> {
pub first_non_special_target: Option<String>,
args: &'a Args,
// TODO borrow warnings from Python version
+ fucking_bullshit_recursion_stack: RefCell<Vec<String>>,
}
impl<'a> Makefile<'a> {
@@ -73,6 +74,7 @@ impl<'a> Makefile<'a> {
targets: RefCell::new(targets),
first_non_special_target,
args,
+ fucking_bullshit_recursion_stack: RefCell::new(Vec::new()),
}
}
@@ -101,6 +103,16 @@ impl<'a> Makefile<'a> {
}
pub fn get_target(&self, name: &str) -> Result<Rc<RefCell<Target>>> {
+ if self
+ .fucking_bullshit_recursion_stack
+ .borrow()
+ .contains(&name.to_owned())
+ {
+ bail!("no infinite recursion allowed");
+ }
+ self.fucking_bullshit_recursion_stack
+ .borrow_mut()
+ .push(name.to_owned());
// TODO implement .POSIX
let follow_gnu = cfg!(feature = "full");
@@ -206,6 +218,8 @@ impl<'a> Makefile<'a> {
.insert(new_target.name.clone(), Rc::new(RefCell::new(new_target)));
}
+ self.fucking_bullshit_recursion_stack.borrow_mut().pop();
+
let targets = self.targets.borrow();
Ok(Rc::clone(
targets