mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-05 12:04:36 -04:00
Correct HamRadio frequency validation (#1266)
This commit is contained in:
parent
fa4623db7c
commit
4ed06b9eff
1 changed files with 12 additions and 5 deletions
|
@ -336,11 +336,18 @@ bool parse_freqman_entry(std::string_view str, freqman_entry& entry) {
|
||||||
if (entry.type == freqman_type::Unknown)
|
if (entry.type == freqman_type::Unknown)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Ranges should have both frequencies set and A <= B.
|
// Frequency A must be set for all types
|
||||||
if (entry.type == freqman_type::Range || entry.type == freqman_type::HamRadio) {
|
if (entry.frequency_a == 0)
|
||||||
if (entry.frequency_a == 0 || entry.frequency_b == 0)
|
return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
|
// Frequency B must be set for type Range or Ham Radio
|
||||||
|
if (entry.type == freqman_type::Range || entry.type == freqman_type::HamRadio) {
|
||||||
|
if (entry.frequency_b == 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ranges should have frequencies A <= B.
|
||||||
|
if (entry.type == freqman_type::Range) {
|
||||||
if (entry.frequency_a > entry.frequency_b)
|
if (entry.frequency_a > entry.frequency_b)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -457,4 +464,4 @@ bool FreqmanDB::empty() const {
|
||||||
// FileWrapper always presents a single line even for empty files.
|
// FileWrapper always presents a single line even for empty files.
|
||||||
// A DB is only really empty if the file size is 0.
|
// A DB is only really empty if the file size is 0.
|
||||||
return !wrapper_ || wrapper_->size() == 0;
|
return !wrapper_ || wrapper_->size() == 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue