#[throws(AE)]
pub fn read(parsed: &mut Parsed, file: &mut dyn BufRead, path_for_loc: &Path) {
let path: Arc<PathBuf> = 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();
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>({
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(),
}
})
} 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()