client: fix minor prefs parsing bug

If we parse for a target venue, and it's present,
and mod_time/source_project/source_scheduler appear after the venue,
we were failing to parse them.
This commit is contained in:
David Anderson 2024-07-23 12:13:51 -07:00
parent ab1085b25f
commit 2b3c19ec0a
1 changed files with 23 additions and 16 deletions

View File

@ -408,15 +408,28 @@ int GLOBAL_PREFS::parse_override(
} }
return 0; return 0;
} }
if (in_venue) { // parse these first; they're independent of venue
if (xp.match_tag("/venue")) { //
if (in_correct_venue) { if (xp.parse_str("source_project", source_project, sizeof(source_project))) {
return 0;
} else {
in_venue = false;
continue; continue;
} }
if (xp.parse_str("source_scheduler", source_scheduler, sizeof(source_scheduler))) {
continue;
}
if (xp.parse_double("mod_time", mod_time)) {
double now = dtime();
if (mod_time > now) {
mod_time = now;
}
continue;
}
if (in_venue) {
if (xp.match_tag("/venue")) {
in_venue = false;
continue;
} else { } else {
// we're in a venue but not the right one; skip tag
//
if (!in_correct_venue) continue; if (!in_correct_venue) continue;
} }
} else { } else {
@ -434,17 +447,11 @@ int GLOBAL_PREFS::parse_override(
} }
continue; continue;
} }
} if (found_venue) {
if (xp.parse_str("source_project", source_project, sizeof(source_project))) continue; // we already found and parsed the target venue;
if (xp.parse_str("source_scheduler", source_scheduler, sizeof(source_scheduler))) { // skip subsequent prefs tags not in a venue
continue; continue;
} }
if (xp.parse_double("mod_time", mod_time)) {
double now = dtime();
if (mod_time > now) {
mod_time = now;
}
continue;
} }
if (xp.parse_double("battery_charge_min_pct", battery_charge_min_pct)) { if (xp.parse_double("battery_charge_min_pct", battery_charge_min_pct)) {
mask.battery_charge_min_pct = true; mask.battery_charge_min_pct = true;