From fbbcf325b8bbe72f924da6a7cdb128d973ef0026 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 11 Nov 2024 14:46:19 -0700 Subject: fix conditional assignment when original is inherited --- src/makefile/macro_scope.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/makefile/macro_scope.rs') diff --git a/src/makefile/macro_scope.rs b/src/makefile/macro_scope.rs index bee603e..ba9b6cf 100644 --- a/src/makefile/macro_scope.rs +++ b/src/makefile/macro_scope.rs @@ -26,7 +26,7 @@ pub trait MacroScope { impl MacroScope for MacroSet { fn get(&self, name: &str) -> Option> { - self.get(name).map(Cow::Borrowed) + self.get_non_recursive(name).map(Cow::Borrowed) } } @@ -82,7 +82,7 @@ impl<'a> MacroScopeStack<'a> { } } - fn get(&self, name: &str) -> Option> { + pub fn get(&self, name: &str) -> Option> { for scope in &self.scopes { if let Some(r#macro) = scope.get(name) { return Some(r#macro); @@ -91,6 +91,11 @@ impl<'a> MacroScopeStack<'a> { None } + #[cfg(feature = "full")] + pub fn is_defined(&self, name: &str) -> bool { + self.get(name).map_or(false, |x| !x.text.is_empty()) + } + pub fn expand<#[cfg(feature = "full")] R: BufRead>( &self, text: &TokenString, -- cgit v1.2.3