From e03d4afd6604b037ebe7551d4c9f8514973ba369 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Aug 2021 20:55:02 +0100 Subject: [PATCH] ini: wip new module Signed-off-by: Ian Jackson --- src/ini.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ini.rs b/src/ini.rs index 67817f5..107f4aa 100644 --- a/src/ini.rs +++ b/src/ini.rs @@ -50,7 +50,7 @@ impl Display for Loc { #[throws(AE)] pub fn read(parsed: &mut Parsed, file: &mut dyn BufRead, path_for_loc: &Path) { let path: Arc = path_for_loc.to_owned().into(); - let section: Option<&mut Section> = None; + let mut section: Option<&mut Section> = None; for (lno, line) in file.lines().enumerate() { let line = line.context("read")?; let line = line.trim(); @@ -58,10 +58,10 @@ pub fn read(parsed: &mut Parsed, file: &mut dyn BufRead, path_for_loc: &Path) { if line.is_empty() { continue } if regex_is_match!(r#"^ [;#] "#x, line) { continue } - let mut loc = Loc { + let loc = Loc { lno, file: path.clone(), - section: section.as_ref().map(|s| s.loc.section.unwrap().clone()), + section: section.as_ref().map(|s| s.loc.section.as_ref().unwrap().clone()), }; (|| Ok::<(),AE>({ @@ -73,7 +73,7 @@ pub fn read(parsed: &mut Parsed, file: &mut dyn BufRead, path_for_loc: &Path) { parsed.entry(new.clone()) .or_insert_with(|| { Section { - loc: Loc { section: Some(new), ..loc }, + loc: Loc { section: Some(new), file: path.clone(), lno }, values: default(), } }) @@ -82,7 +82,7 @@ pub fn read(parsed: &mut Parsed, file: &mut dyn BufRead, path_for_loc: &Path) { } else if let Some((_, key, val)) = regex_captures!(r#"^ ( [^\[] .*? ) \s* = \s* (.*) $"#, line) { - let val = Val { loc, val: val.into() }; + let val = Val { loc: loc.clone(), val: val.into() }; section .as_mut() -- 2.30.2