diff options
Diffstat (limited to 'src/macro_processor/macro_processor.rs')
-rw-r--r-- | src/macro_processor/macro_processor.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 68347d0..3164aa6 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -152,6 +152,19 @@ fn smp_builtin_include( return smp.process_input(&input_file); } +/// Include a new file verbatum, don't do ANY additional processing +fn smp_builtin_include_verbatum( + smp: &mut MacroProcessor, + macro_name: &str, + args: &mut [String], +) -> Result<String, SMPError> { + if args.len() < 1 { + return Ok(macro_name.to_string()); + } + let arg0 = smp.process_input(&args[0])?; + fs::read_to_string(&arg0).map_err(|e| SMPError::IncludeError(2, e, arg0)) +} + /// Simply execute argument as shell command fn smp_builtin_shell( smp: &mut MacroProcessor, @@ -258,6 +271,10 @@ impl MacroProcessor { MacroType::Function(smp_builtin_include), ); self.define_macro( + String::from("include_verbatum"), + MacroType::Function(smp_builtin_include_verbatum), + ); + self.define_macro( String::from("shell"), MacroType::Function(smp_builtin_shell), ); |