mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-22 12:47:45 +00:00
Make EXL parsing more resilient
It now stops tripping up over basic parsing errors and comments.
This commit is contained in:
parent
4fa77965c1
commit
04025e0707
1 changed files with 11 additions and 9 deletions
20
src/exl.rs
20
src/exl.rs
|
@ -24,18 +24,20 @@ impl EXL {
|
||||||
let cursor = Cursor::new(buffer);
|
let cursor = Cursor::new(buffer);
|
||||||
let reader = BufReader::new(cursor);
|
let reader = BufReader::new(cursor);
|
||||||
|
|
||||||
for (_, line) in reader.lines().enumerate() {
|
for line in reader.lines() {
|
||||||
// now parse the line!
|
// now parse the line!
|
||||||
|
|
||||||
let unwrap = line.unwrap();
|
if let Ok(line) = line {
|
||||||
let (name, value) = unwrap.split_once(',').unwrap();
|
if let Some((name, value)) = line.split_once(',') {
|
||||||
|
let parsed_value: i32 = value.parse().unwrap();
|
||||||
|
|
||||||
let parsed_value: i32 = value.parse().unwrap();
|
if name == "EXLT" {
|
||||||
|
exl.version = parsed_value;
|
||||||
if name == "EXLT" {
|
} else if !name.starts_with('#') {
|
||||||
exl.version = parsed_value;
|
// Ignore rows with comments
|
||||||
} else {
|
exl.entries.push((name.parse().unwrap(), parsed_value));
|
||||||
exl.entries.push((name.parse().unwrap(), parsed_value));
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue