diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-09-10 15:29:03 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2019-09-10 21:31:21 +0200 |
commit | ee365b734119be424e48c4a2cef5f54021521cb8 (patch) | |
tree | 65751a173a73e01a5fd05b0d437bf4070dfaa511 /core/plannernotes.c | |
parent | 4706b0f11ae335c1d23e1334b3530fce1a2c9279 (diff) | |
download | subsurface-ee365b734119be424e48c4a2cef5f54021521cb8.tar.gz |
Plan: introduce function that returns disclaimer
The setting of the disclaimer variable was removed inadvertently
some time ago, which removed the disclaimer from the printed plan.
Instead, introduce a function that returns the disclaimer with
the current deco mode. Use that function to generate the dive
notes and for printing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/plannernotes.c')
-rw-r--r-- | core/plannernotes.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/core/plannernotes.c b/core/plannernotes.c index 6714d360a..8d1f04731 100644 --- a/core/plannernotes.c +++ b/core/plannernotes.c @@ -82,11 +82,21 @@ const char *get_planner_disclaimer() "PLAN DIVES SIMPLY BASED ON THE RESULTS GIVEN HERE."); } +/* Returns newly allocated buffer. Must be freed by caller */ +char *get_planner_disclaimer_formatted() +{ + struct membuffer buf = { 0 }; + const char *deco = decoMode() == VPMB ? translate("gettextFromC", "VPM-B") + : translate("gettextFromC", "BUHLMANN"); + put_format(&buf, get_planner_disclaimer(), deco); + return detach_buffer(&buf); +} + void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer, int error) { struct membuffer buf = { 0 }; struct membuffer icdbuf = { 0 }; - const char *deco, *segmentsymbol; + const char *segmentsymbol; int lastdepth = 0, lasttime = 0, lastsetpoint = -1, newdepth = 0, lastprintdepth = 0, lastprintsetpoint = -1; struct gasmix lastprintgasmix = gasmix_invalid; struct divedatapoint *dp = diveplan->dp; @@ -106,12 +116,6 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d struct icd_data icdvalues; char *temp; - if (decoMode() == VPMB) { - deco = translate("gettextFromC", "VPM-B"); - } else { - deco = translate("gettextFromC", "BUHLMANN"); - } - if (!dp) return; @@ -123,9 +127,11 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d } if (show_disclaimer) { + char *disclaimer = get_planner_disclaimer_formatted(); put_string(&buf, "<div><b>"); - put_format(&buf, get_planner_disclaimer(), deco); + put_string(&buf, disclaimer); put_string(&buf, "</b><br></div>"); + free(disclaimer); } if (diveplan->surface_interval < 0) { |