From 06f3de418030b4c03a61d7bf43f19282e76af23e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 15 May 2022 16:48:51 +0100 Subject: [PATCH] shapelib, subst: Allow groups to provide magic substs Otherwise they might have to recapitulate the template. Signed-off-by: Ian Jackson --- src/shapelib-toml.rs | 1 + src/shapelib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/shapelib-toml.rs b/src/shapelib-toml.rs index 5dd16c5d..5de8d572 100644 --- a/src/shapelib-toml.rs +++ b/src/shapelib-toml.rs @@ -37,6 +37,7 @@ pub struct MagicDetails { #[serde(default)] pub item_prefix: String, #[serde(default)] pub item_suffix: String, pub template: String, + #[serde(default)] pub substs: HashMap, } #[derive(Debug,Deserialize,Copy,Clone)] diff --git a/src/shapelib.rs b/src/shapelib.rs index f4adef5a..a3d71d31 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -1444,6 +1444,7 @@ fn process_files_entry( let mut spec = c_colour_all(spec.into())?.is_y()?; for (k,v) in chain!{ fe.extra_fields.iter().filter(|(k,_v)| k.starts_with('x')), + &magic.substs, } { spec = substn(spec, format!("${{{}}}", k), v)?; } -- 2.30.2