From e897b95b6229575210dcb580bdb2b79adeaeae26 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 19 Dec 2012 12:36:56 -0800 Subject: [PATCH] Prevent bleeding deco/ndl for XML files without divecomputer entries Miika's xslt patch creates correct XML data without divecomputer entries. What happens is that the stop information at xml parse time is only cleared by the divecomputer entries, so if the XML lacks them, we will bleed stop data from one dive to the next. This patch makes sure that the deco/ndl information is cleared even if the dive has no divecomputer entry. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- parse-xml.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/parse-xml.c b/parse-xml.c index dd35379fb..7d9a4694d 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -985,11 +985,17 @@ static gboolean is_dive(void) (cur_dive->location || cur_dive->when || cur_dive->dc.samples)); } +static void reset_dc_info(struct divecomputer *dc) +{ + lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = 0; +} + static void dive_start(void) { if (cur_dive) return; cur_dive = alloc_dive(); + reset_dc_info(&cur_dive->dc); memset(&cur_tm, 0, sizeof(cur_tm)); if (cur_trip) { add_dive_to_trip(cur_dive, cur_trip); @@ -1115,8 +1121,7 @@ static void divecomputer_start(void) /* .. this is the one we'll use */ cur_dc = dc; - - lastcns = lastpo2 = lastndl = laststoptime = laststopdepth = 0; + reset_dc_info(dc); } static void divecomputer_end(void)