diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-09-06 12:39:51 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-09-06 12:59:54 -0700 |
commit | 7f1def86021eda8cc01911b4944be4bc38ae65fe (patch) | |
tree | 49eec74b2d0a4789e328f9f1728be3aeb882e72f /core/load-git.c | |
parent | 55e42373066ade9ad2e1a51adf27a0a28cb0d02a (diff) | |
download | subsurface-7f1def86021eda8cc01911b4944be4bc38ae65fe.tar.gz |
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>
Diffstat (limited to 'core/load-git.c')
-rw-r--r-- | core/load-git.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/core/load-git.c b/core/load-git.c index 49482b6c6..444303399 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -309,15 +309,10 @@ static void parse_site_gps(char *line, struct membuffer *str, struct git_parser_ static void parse_site_geo(char *line, struct membuffer *str, struct git_parser_state *state) { - if (state->active_site->taxonomy.category == NULL) - state->active_site->taxonomy.category = alloc_taxonomy(); - int nr = state->active_site->taxonomy.nr; - if (nr < TC_NR_CATEGORIES) { - struct taxonomy *t = &state->active_site->taxonomy.category[nr]; - t->value = detach_cstring(str); - sscanf(line, "cat %d origin %d \"", &t->category, (int *)&t->origin); - state->active_site->taxonomy.nr++; - } + int origin; + int category; + sscanf(line, "cat %d origin %d \"", &category, &origin); + taxonomy_set_category(&state->active_site->taxonomy , category, mb_cstring(str), origin); } static char *remove_from_front(struct membuffer *str, int len) |