mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: use case-insensitive comparison for device models
The code in core/libdivecomputer.c used string insensitive comparison for device models, before being merged into core/device.c. Let's reinstate that behavior, since it appears to be more logical. On would assume that two different vendors will not use the same model with different casing (and the same device-ids), so that should be safe. This uses strcoll to correctly sort unicode, which will hopefully never be needed! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0c769b04b7
commit
1d6c1db4a5
1 changed files with 6 additions and 1 deletions
|
@ -205,7 +205,12 @@ bool device::operator==(const device &a) const
|
|||
|
||||
bool device::operator<(const device &a) const
|
||||
{
|
||||
return std::tie(deviceId, model) < std::tie(a.deviceId, a.model);
|
||||
if (deviceId != a.deviceId)
|
||||
return deviceId < a.deviceId;
|
||||
|
||||
// Use strcoll to compare model-strings, since these might be unicode
|
||||
// and therefore locale dependent? Let's hope that not, but who knows?
|
||||
return strcoll(model.c_str(), a.model.c_str()) < 0;
|
||||
}
|
||||
|
||||
const struct device *get_device_for_dc(const struct device_table *table, const struct divecomputer *dc)
|
||||
|
|
Loading…
Reference in a new issue