From: Ian Jackson Date: Sun, 15 May 2022 15:48:51 +0000 (+0100) Subject: shapelib, subst: Allow groups to provide magic substs X-Git-Tag: otter-1.1.0~103 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=06f3de418030b4c03a61d7bf43f19282e76af23e;p=otter.git shapelib, subst: Allow groups to provide magic substs Otherwise they might have to recapitulate the template. Signed-off-by: Ian Jackson --- 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)?; }