aboutsummaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-04-09 13:06:30 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-04-09 13:06:30 -0700
commit9e4f9fad19bd4696bf08da67b60ed9d2eb29b446 (patch)
tree762d87bb965705c6d51b89c6abf594e6c5b6bba5 /parse-xml.c
parented3f67bc33fbd9aac819687317d3066c22799f83 (diff)
downloadsubsurface-9e4f9fad19bd4696bf08da67b60ed9d2eb29b446.tar.gz
Store the tag names instead of an opaque number
And as we need the names for that, simplify the way we show the tags in the Dive Info tab (and mark them for translation while we are at it). In the process I renamed the constants to DTAG_ from DTYPE_ (and made their nature as being just bits more obvious). Also mark the box on the Info tab "Dive Tags", not "Dive Type". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 431cd376d..57b022bb0 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -200,6 +200,29 @@ static void divedatetime(char *buffer, void *_when)
}
}
+static void divetags(char *buffer, void *_tags)
+{
+ int *tags = _tags;
+ int i;
+
+ *tags = 0;
+ for (i = 0; i < DTAG_NR; i++) {
+ if (strstr(buffer, dtag_names[i])) {
+ /* stupidly we have 'cave' and 'cavern' */
+ if (1 << i == DTAG_CAVE) {
+ char *cave = strstr(buffer, "cave");
+ while (cave && !strncmp(cave, "cavern", strlen("cavern"))) {
+ cave++;
+ cave = strstr(cave, "cave");
+ }
+ if (!cave)
+ continue;
+ }
+ *tags |= (1 << i);
+ }
+ }
+}
+
enum number_type {
NEITHER,
FLOAT
@@ -1033,7 +1056,7 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
if (MATCH(".number", get_index, &dive->number))
return;
- if (MATCH(".tags", get_index, &dive->dive_tags))
+ if (MATCH(".tags", divetags, &dive->dive_tags))
return;
if (MATCH(".tripflag", get_tripflag, &dive->tripflag))
return;