From 6fe8cb652191728586f3731dcf6688b5a5b3efbb Mon Sep 17 00:00:00 2001 From: Maximilian Güntner Date: Sat, 2 Nov 2013 02:12:42 +0100 Subject: Replaced the tag implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new implementation supports custom tags which are provided by the user as well as default tags which are provided by subsurface. Default tags can be translated and will be written to XML in their non-localized form. Signed-off-by: Maximilian Güntner --- save-xml.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'save-xml.c') diff --git a/save-xml.c b/save-xml.c index ab81c1590..5b0ef42ec 100644 --- a/save-xml.c +++ b/save-xml.c @@ -392,20 +392,28 @@ static void save_events(FILE *f, struct event *ev) } } -static void save_tags(FILE *f, int tags) +static void save_tags(FILE *f, struct tag_entry *tag_list) { - int i, more = 0; + int more = 0; + struct tag_entry *tmp = tag_list->next; - fprintf(f, " tags='"); - for (i = 0; i < DTAG_NR; i++) { - if (tags & (1 << i)) { + /* Only write tag attribute if the list contains at least one item */ + if (tmp != NULL) { + fprintf(f, " tags='"); + + while (tmp != NULL) { if (more) fprintf(f, ", "); - fprintf(f, "%s", dtag_names[i]); + /* If the tag has been translated, write the source to the xml file */ + if (tmp->tag->source != NULL) + fprintf(f, "%s", tmp->tag->source); + else + fprintf(f, "%s", tmp->tag->name); + tmp = tmp->next; more = 1; } + fprintf(f, "'"); } - fprintf(f, "'"); } static void show_date(FILE *f, timestamp_t when) @@ -468,8 +476,8 @@ void save_dive(FILE *f, struct dive *dive) fprintf(f, " rating='%d'", dive->rating); if (dive->visibility) fprintf(f, " visibility='%d'", dive->visibility); - if (dive->dive_tags) - save_tags(f, dive->dive_tags); + if (dive->tag_list != NULL) + save_tags(f, dive->tag_list); show_date(f, dive->when); fprintf(f, " duration='%u:%02u min'>\n", -- cgit v1.2.3-70-g09d2