From 361ddd96344ece56e8d2059375b45b13c0532c86 Mon Sep 17 00:00:00 2001 From: Rick Walsh Date: Thu, 23 Jul 2015 23:36:11 +1000 Subject: Planner: correct output of planner mode Previously we used strncat to output VPM mode without correctly defining the length of the string, and didn't do anything for recreational mode. This resulted in the output being junk recycled from the previous temp string. We could use strncat if the string length were defined, but using snprintf will make it simpler to include the VPM conservatism when that has been implemented. Signed-off-by: Rick Walsh Signed-off-by: Dirk Hohndel --- planner.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/planner.c b/planner.c index e5685a499..9fe5c1d05 100644 --- a/planner.c +++ b/planner.c @@ -542,7 +542,10 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool snprintf(temp, sizeof(temp), translate("gettextFromC", "based on Buhlmann ZHL-16B with GFlow = %d and GFhigh = %d"), diveplan->gflow, diveplan->gfhigh); } else if (prefs.deco_mode == VPMB){ - strncat(temp, translate("gettextFromC", "based on VPM-B"), sizeof(temp) - 1); + snprintf(temp, sizeof(temp), translate("gettextFromC", "based on VPM-B")); + } else if (prefs.deco_mode == RECREATIONAL){ + snprintf(temp, sizeof(temp), translate("gettextFromC", "recreational mode based on Buhlmann ZHL-16B with GFlow = %d and GFhigh = %d"), + diveplan->gflow, diveplan->gfhigh); } len += snprintf(buffer + len, sizeof(buffer) - len, "
%s
%s

", translate("gettextFromC", "Subsurface dive plan"), temp); -- cgit v1.2.3-70-g09d2