aboutsummaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-10-05 08:31:31 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-10-05 08:31:31 -0700
commitd6c2236b8a9e20d22d78de7432f7017a18235619 (patch)
treeaa2c73f2afd72c0d49ffa585dc53d0e4748f4635 /libdivecomputer.c
parentf4820455e2019c1a9deba7e90ed7f06111a4cb39 (diff)
downloadsubsurface-d6c2236b8a9e20d22d78de7432f7017a18235619.tar.gz
Automatically renumber new dives when they are "obvious".
When importing (or reading xml from files) new dives, we now renumber them based on preexisting dive data, *if* such re-numbering is obvious. NOTE! In order to be "obvious", there can be no overlap between old and new dives: all the new dives have to come at the end. That's what happens with a normal libdivecomputer import, since we cut the import short when we find a preexisting dive. But if any of the new dives overlap the old dives in any way, or already have been numbered separately, the automatic renumbering is not done, and you need to do a manual renumber. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r--libdivecomputer.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 78be2019a..bcf59eeb5 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -223,7 +223,7 @@ static int find_dive(struct dive *dive, device_data_t *devdata)
{
int i;
- for (i = 0; i < devdata->preexisting; i++) {
+ for (i = 0; i < dive_table.preexisting; i++) {
struct dive *old = dive_table.dives[i];
if (dive->when != old->when)
@@ -333,7 +333,6 @@ static int dive_cb(const unsigned char *data, unsigned int size,
static device_status_t import_device_data(device_t *device, device_data_t *devicedata)
{
- devicedata->preexisting = dive_table.nr;
return device_foreach(device, dive_cb, devicedata);
}