summaryrefslogtreecommitdiffstats
path: root/core/device.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-14 22:15:32 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-16 14:26:37 -0700
commit1d6c1db4a5808da55b0b49f3d6460f3f10f5e917 (patch)
treec5ba434a26ad10b411fd2d1691cd3887f3c86d15 /core/device.cpp
parent0c769b04b72a1805e1ffa32b4fca5f59fc98431a (diff)
downloadsubsurface-1d6c1db4a5808da55b0b49f3d6460f3f10f5e917.tar.gz
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>
Diffstat (limited to 'core/device.cpp')
-rw-r--r--core/device.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/device.cpp b/core/device.cpp
index 4bfdd3ea4..c35aa74e9 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -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)