diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-11-13 12:45:32 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-13 12:45:32 -0800 |
commit | 8086b39e11da344f9c931ea8d325d2ef94982913 (patch) | |
tree | 9c8ba1440ed46a1412ebaf2483d42c8d073b2bf3 /dive.c | |
parent | dae76cdc2dad1ec49520c6cb23530adaa5a6134a (diff) | |
download | subsurface-8086b39e11da344f9c931ea8d325d2ef94982913.tar.gz |
Adjust the counter function for filter with "none of the above"
So this should count dives with neither buddy nor divemaster, without a
location, with no tags, etc.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -2507,8 +2507,13 @@ int count_dives_with_tag(const char *tag) struct dive *d; for_each_dive (i, d) { - if (taglist_contains(d->tag_list, tag)) + if (same_string(tag, "")) { + // count dives with no tags + if (d->tag_list == NULL) + counter++; + } else if (taglist_contains(d->tag_list, tag)) { counter++; + } } return counter; } @@ -2522,8 +2527,13 @@ int count_dives_with_person(const char *person) struct dive *d; for_each_dive (i, d) { - if (string_sequence_contains(d->buddy, person) || string_sequence_contains(d->divemaster, person)) + if (same_string(person, "")) { + // solo dive + if (same_string(d->buddy, "") && same_string(d->divemaster, "")) + counter++; + } else if (string_sequence_contains(d->buddy, person) || string_sequence_contains(d->divemaster, person)) { counter++; + } } return counter; } |