From 44b3ea4dac1cc60eeda54ae7b53facbb025c6f68 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 13 Nov 2024 00:27:03 -0700 Subject: fix rule macro detection when macro expansion in macro name --- src/makefile/token.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/makefile/token.rs') diff --git a/src/makefile/token.rs b/src/makefile/token.rs index dad4694..7b88823 100644 --- a/src/makefile/token.rs +++ b/src/makefile/token.rs @@ -155,6 +155,19 @@ impl TokenString { } }) } + + /// Returns (token index within string, pattern index within token). + pub fn find(&self, pattern: &str) -> Option<(usize, usize)> { + self.0 + .iter() + .enumerate() + .find_map(|(token_index, token)| match token { + Token::Text(text) => text + .find(pattern) + .map(|pattern_index| (token_index, pattern_index)), + _ => None, + }) + } } impl fmt::Display for TokenString { -- cgit v1.2.3