diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-02-10 06:31:37 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-10 06:31:37 -0800 |
commit | 585d6a004b4533c72ebfd70664571931dcc0ccd0 (patch) | |
tree | 4aa7663bcc9f42bb9710b1c56548759a3dabc80e /dive.c | |
parent | d60a6201931ed11e019e7582a6d6f72d6f4e0400 (diff) | |
download | subsurface-585d6a004b4533c72ebfd70664571931dcc0ccd0.tar.gz |
Only update tags in the selected dives if they were changed
If current_dive and displayed_dive still have the same tags then we
shouldn't touch the tags of other selected dives.
Fixes #826
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -2618,6 +2618,24 @@ bool taglist_contains(struct tag_entry *tag_list, const char *tag) return false; } +// check if all tags in subtl are included in supertl (so subtl is a subset of supertl) +static bool taglist_contains_all(struct tag_entry *subtl, struct tag_entry *supertl) +{ + while (subtl) { + if (!taglist_contains(supertl, subtl->tag->name)) + return false; + subtl = subtl->next; + } + return true; + +} + +// if tl1 is both a subset and superset of tl2 they must be the same +bool taglist_equal(struct tag_entry *tl1, struct tag_entry *tl2) +{ + return taglist_contains_all(tl1, tl2) && taglist_contains_all(tl2, tl1); +} + // count the dives where the tag list contains the given tag int count_dives_with_tag(const char *tag) { |