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:
Berthold Stoeger 2020-10-14 22:15:32 +02:00 committed by Dirk Hohndel
parent 0c769b04b7
commit 1d6c1db4a5

View file

@ -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)