summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse-xml.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 5061227e3..30b616324 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -168,25 +168,26 @@ static enum import_source {
static void divedate(char *buffer, void *_when)
{
int d,m,y;
+ int hh,mm,ss;
timestamp_t *when = _when;
- int success;
- success = cur_tm.tm_sec | cur_tm.tm_min | cur_tm.tm_hour;
- if (sscanf(buffer, "%d.%d.%d", &d, &m, &y) == 3) {
- cur_tm.tm_year = y;
- cur_tm.tm_mon = m-1;
- cur_tm.tm_mday = d;
- } else if (sscanf(buffer, "%d-%d-%d", &y, &m, &d) == 3) {
- cur_tm.tm_year = y;
- cur_tm.tm_mon = m-1;
- cur_tm.tm_mday = d;
+ hh = 0; mm = 0; ss = 0;
+ if (sscanf(buffer, "%d.%d.%d %d:%d:%d", &d, &m, &y, &hh, &mm, &ss) >= 3) {
+ /* This is ok, and we got at least the date */
+ } else if (sscanf(buffer, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) >= 3) {
+ /* This is also ok */
} else {
fprintf(stderr, "Unable to parse date '%s'\n", buffer);
- success = 0;
+ return;
}
+ cur_tm.tm_year = y;
+ cur_tm.tm_mon = m-1;
+ cur_tm.tm_mday = d;
+ cur_tm.tm_hour = hh;
+ cur_tm.tm_min = mm;
+ cur_tm.tm_sec = ss;
- if (success)
- *when = utc_mktime(&cur_tm);
+ *when = utc_mktime(&cur_tm);
}
static void divetime(char *buffer, void *_when)
@@ -198,8 +199,7 @@ static void divetime(char *buffer, void *_when)
cur_tm.tm_hour = h;
cur_tm.tm_min = m;
cur_tm.tm_sec = s;
- if (cur_tm.tm_year)
- *when = utc_mktime(&cur_tm);
+ *when = utc_mktime(&cur_tm);
}
}
@@ -1004,8 +1004,12 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf)
return;
if (MATCH(".latitude", gps_lat, dive))
return;
+ if (MATCH(".sitelat", gps_lat, dive))
+ return;
if (MATCH(".longitude", gps_long, dive))
return;
+ if (MATCH(".sitelon", gps_long, dive))
+ return;
if (MATCH(".location", utf8_string, &dive->location))
return;
if (MATCH("dive.name", utf8_string, &dive->location))
@@ -1346,7 +1350,7 @@ static void visit_one_node(xmlNode *node)
return;
/* Don't print out the node name if it is "text" */
- if (!strcmp(node->name, "text"))
+ while (!node->name || !strcmp(node->name, "text"))
node = node->parent;
name = nodename(node, buffer, sizeof(buffer));
@@ -1434,6 +1438,11 @@ static void traverse(xmlNode *root)
for (n = root; n; n = n->next) {
struct nesting *rule = nesting;
+ if (!n->name) {
+ visit(n);
+ continue;
+ }
+
do {
if (!strcmp(rule->name, n->name))
break;