summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-02 12:16:03 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-02 17:02:21 -0700
commite077206bb8aa5a08945b56da1b4dafa32acb6c65 (patch)
treedb6cf0c343531d5d498057ea55edd922b521f8d7
parent5810aedeac5cbcc2500d6bbe9c65aea6b1c40a8c (diff)
downloadsubsurface-e077206bb8aa5a08945b56da1b4dafa32acb6c65.tar.gz
Tag list handling: add two new helpers
taglist_added() simply figures out the tags that are in the new list but not in the original list. taglist_dump() makes debugging things easier. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.c22
-rw-r--r--dive.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index fe7807c5e..1ee84b631 100644
--- a/dive.c
+++ b/dive.c
@@ -2645,7 +2645,29 @@ static bool taglist_contains_all(struct tag_entry *subtl, struct tag_entry *supe
subtl = subtl->next;
}
return true;
+}
+struct tag_entry *taglist_added(struct tag_entry *original_list, struct tag_entry *new_list)
+{
+ struct tag_entry *added_list = NULL;
+ while (new_list) {
+ if (!taglist_contains(original_list, new_list->tag->name))
+ taglist_add_tag(&added_list, new_list->tag->name);
+ new_list = new_list->next;
+ }
+ return added_list;
+}
+
+void dump_taglist(const char *intro, struct tag_entry *tl)
+{
+ char *comma = "";
+ fprintf(stderr, "%s", intro);
+ while(tl) {
+ fprintf(stderr, "%s %s", comma, tl->tag->name);
+ comma = ",";
+ tl = tl->next;
+ }
+ fprintf(stderr, "\n");
}
// if tl1 is both a subset and superset of tl2 they must be the same
diff --git a/dive.h b/dive.h
index b350527a7..9e86b74f9 100644
--- a/dive.h
+++ b/dive.h
@@ -224,6 +224,8 @@ struct tag_entry {
extern struct tag_entry *g_tag_list;
struct divetag *taglist_add_tag(struct tag_entry **tag_list, const char *tag);
+struct tag_entry *taglist_added(struct tag_entry *original_list, struct tag_entry *new_list);
+void dump_taglist(const char *intro, struct tag_entry *tl);
/*
* Writes all divetags in tag_list to buffer, limited by the buffer's (len)gth.