cleanup: use taxonomy_set_category() function

Instead of manipulating the taxonomy structures directly, use the
taxonomy_set_category() function. This improves encapsulation and
gives us the possibility to improve the taxonomy data structures.

This concerns three places:
1) git parser
2) XML parser
3) reverse geo-lookup

This improves the XML parser code slightly: The parser assumes that
the value-attribute comes last (after origin and category). While
it still does that, it now at least generates a warning if it encounters
a value-attribute without origin- or category-attribute.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-09-06 12:39:51 +02:00 committed by Dirk Hohndel
parent 55e4237306
commit 7f1def8602
5 changed files with 32 additions and 38 deletions

View file

@ -203,6 +203,8 @@ void dive_site_start(struct parser_state *state)
{
if (state->cur_dive_site)
return;
state->taxonomy_category = -1;
state->taxonomy_origin = -1;
state->cur_dive_site = calloc(1, sizeof(struct dive_site));
}
@ -210,10 +212,6 @@ void dive_site_end(struct parser_state *state)
{
if (!state->cur_dive_site)
return;
if (state->cur_dive_site->taxonomy.nr == 0) {
free(state->cur_dive_site->taxonomy.category);
state->cur_dive_site->taxonomy.category = NULL;
}
if (state->cur_dive_site->uuid) {
struct dive_site *ds = alloc_or_get_dive_site(state->cur_dive_site->uuid, state->sites);
merge_dive_site(ds, state->cur_dive_site);