diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/makefile/functions.rs | 16 | 
1 files changed, 16 insertions, 0 deletions
| diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs index 6e9d3cb..46caca5 100644 --- a/src/makefile/functions.rs +++ b/src/makefile/functions.rs @@ -16,6 +16,10 @@ pub fn expand_call(      to_eval: Option<Rc<RefCell<Vec<String>>>>,  ) -> Result<String> {      match name { +        "subst" => { +            assert_eq!(args.len(), 3); +            text::subst(macros, &args[0], &args[1], &args[2]) +        }          "strip" => {              assert_eq!(args.len(), 1);              text::strip(macros, &args[0]) @@ -123,6 +127,18 @@ pub fn expand_call(  mod text {      use super::*; +    pub fn subst( +        macros: &MacroSet, +        from: &TokenString, +        to: &TokenString, +        text: &TokenString, +    ) -> Result<String> { +        let from = macros.expand(from)?; +        let to = macros.expand(to)?; +        let text = macros.expand(text)?; +        Ok(text.replace(&from, &to)) +    } +      pub fn strip(macros: &MacroSet, text: &TokenString) -> Result<String> {          let text = macros.expand(text)?;          // TODO don't allocate this vec |