diff options
author | Melody Horn <melody@boringcactus.com> | 2024-11-11 14:46:19 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-11-11 14:46:19 -0700 |
commit | fbbcf325b8bbe72f924da6a7cdb128d973ef0026 (patch) | |
tree | 783dc988b77c95fd739b30a436a496b7c0c550c2 /src/makefile/macro_scope.rs | |
parent | 5aa6e1122830611dccc2eab9b7f4a53a10056111 (diff) | |
download | makers-fbbcf325b8bbe72f924da6a7cdb128d973ef0026.tar.gz makers-fbbcf325b8bbe72f924da6a7cdb128d973ef0026.zip |
fix conditional assignment when original is inherited
Diffstat (limited to 'src/makefile/macro_scope.rs')
-rw-r--r-- | src/makefile/macro_scope.rs | 9 |
1 files changed, 7 insertions, 2 deletions
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<Cow<Macro>> { - 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<Cow<Macro>> { + pub fn get(&self, name: &str) -> Option<Cow<Macro>> { 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, |