Save XML: sort the dive sites by uuid

This makes it much easier to compare XML files written by Subsurface.
The order of the dive_site_table depended on the order in which they were
encountered. This makes it easier to eye-ball changes in XML files. And
allows the GitStorage test to pass.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-08-24 11:07:57 -07:00
parent e03b553e80
commit 420afeef57
3 changed files with 15 additions and 1 deletions

View file

@ -263,3 +263,15 @@ uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t diveti
return ds->uuid;
return create_dive_site(name, divetime);
}
static int compare_sites(const void *_a, const void *_b)
{
const struct dive_site *a = (const struct dive_site *)*(void **)_a;
const struct dive_site *b = (const struct dive_site *)*(void **)_b;
return a->uuid > b->uuid ? 1 : a->uuid == b->uuid ? 0 : -1;
}
void dive_site_table_sort()
{
qsort(dive_site_table.dive_sites, dive_site_table.nr, sizeof(struct dive_site *), compare_sites);
}