Deal with some of the whitespace issues in planner.c

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-02-03 03:10:57 -08:00
parent fbaeeec807
commit 414d7f2632

View file

@ -411,7 +411,7 @@ struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration,
struct divedatapoint *dp = create_dp(duration, depth, cylinderid, po2); struct divedatapoint *dp = create_dp(duration, depth, cylinderid, po2);
dp->entered = entered; dp->entered = entered;
add_to_end_of_diveplan(diveplan, dp); add_to_end_of_diveplan(diveplan, dp);
return (dp); return dp;
} }
struct gaschanges { struct gaschanges {
@ -589,7 +589,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s</b></div>", len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s</b></div>",
translate("gettextFromC", "Subsurface dive plan")); translate("gettextFromC", "Subsurface dive plan"));
} }
len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>Runtime: %dmin</div><br>"), len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>Runtime: %dmin</div><br>"),
diveplan_duration(diveplan)); diveplan_duration(diveplan));
@ -788,7 +788,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
} while ((dp = nextdp) != NULL); } while ((dp = nextdp) != NULL);
if (!plan_verbatim) if (!plan_verbatim)
len += snprintf(buffer + len, sz_buffer - len, "</tbody></table></div>"); len += snprintf(buffer + len, sz_buffer - len, "</tbody></table></div>");
/* Print the CNS and OTU next.*/ /* Print the CNS and OTU next.*/
dive->cns = 0; dive->cns = 0;
dive->maxcns = 0; dive->maxcns = 0;
@ -796,8 +796,8 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
snprintf(temp, sz_temp, "%s", translate("gettextFromC", "CNS")); snprintf(temp, sz_temp, "%s", translate("gettextFromC", "CNS"));
len += snprintf(buffer + len, sz_buffer - len, "<div><br>%s: %i%%", temp, dive->cns); len += snprintf(buffer + len, sz_buffer - len, "<div><br>%s: %i%%", temp, dive->cns);
snprintf(temp, sz_temp, "%s", translate("gettextFromC", "OTU")); snprintf(temp, sz_temp, "%s", translate("gettextFromC", "OTU"));
len += snprintf(buffer + len, sz_buffer - len, "<br>%s: %i</div>", temp, dive->otu); len += snprintf(buffer + len, sz_buffer - len, "<br>%s: %i</div>", temp, dive->otu);
/* Print the settings for the diveplan next. */ /* Print the settings for the diveplan next. */
if (decoMode() == BUEHLMANN){ if (decoMode() == BUEHLMANN){
snprintf(temp, sz_temp, translate("gettextFromC", "Deco model: Bühlmann ZHL-16C with GFlow = %d and GFhigh = %d"), snprintf(temp, sz_temp, translate("gettextFromC", "Deco model: Bühlmann ZHL-16C with GFlow = %d and GFhigh = %d"),
@ -808,7 +808,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
temp_len = snprintf(temp, sz_temp, "%s", translate("gettextFromC", "Deco model: VPM-B at nominal conservatism")); temp_len = snprintf(temp, sz_temp, "%s", translate("gettextFromC", "Deco model: VPM-B at nominal conservatism"));
else else
temp_len = snprintf(temp, sz_temp, translate("gettextFromC", "Deco model: VPM-B at +%d conservatism"), diveplan->vpmb_conservatism); temp_len = snprintf(temp, sz_temp, translate("gettextFromC", "Deco model: VPM-B at +%d conservatism"), diveplan->vpmb_conservatism);
if(diveplan->eff_gflow) if (diveplan->eff_gflow)
temp_len += snprintf(temp + temp_len, sz_temp - temp_len, translate("gettextFromC", ", effective GF=%d/%d"), diveplan->eff_gflow temp_len += snprintf(temp + temp_len, sz_temp - temp_len, translate("gettextFromC", ", effective GF=%d/%d"), diveplan->eff_gflow
, diveplan->eff_gfhigh); , diveplan->eff_gfhigh);
@ -817,10 +817,10 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
diveplan->gflow, diveplan->gfhigh); diveplan->gflow, diveplan->gfhigh);
} }
len += snprintf(buffer + len, sz_buffer - len, "<div><br>%s</div>",temp); len += snprintf(buffer + len, sz_buffer - len, "<div><br>%s</div>",temp);
const char *depth_unit; const char *depth_unit;
int altitude = (int) get_depth_units((int) (log(1013.0 / diveplan->surface_pressure) * 7800000), NULL, &depth_unit); int altitude = (int) get_depth_units((int) (log(1013.0 / diveplan->surface_pressure) * 7800000), NULL, &depth_unit);
len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>ATM pressure: %dmbar (%d%s)</div>"), len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>ATM pressure: %dmbar (%d%s)</div>"),
diveplan->surface_pressure, diveplan->surface_pressure,
altitude, altitude,
@ -833,11 +833,11 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
bottomsacvalue = get_volume_units(prefs.bottomsac, &sacdecimals, &sacunit); bottomsacvalue = get_volume_units(prefs.bottomsac, &sacdecimals, &sacunit);
decosacvalue = get_volume_units(prefs.decosac, NULL, NULL); decosacvalue = get_volume_units(prefs.decosac, NULL, NULL);
/* Reduce number of decimals from 1 to 0 for bar/min, keep 2 for cuft/min */ /* Reduce number of decimals from 1 to 0 for bar/min, keep 2 for cuft/min */
if (sacdecimals==1) sacdecimals--; if (sacdecimals==1) sacdecimals--;
/* Print the gas consumption next.*/ /* Print the gas consumption next.*/
if (dive->dc.divemode == CCR) if (dive->dc.divemode == CCR)
snprintf(temp, sz_temp, "%s", translate("gettextFromC", "Gas consumption (CCR legs excluded):")); snprintf(temp, sz_temp, "%s", translate("gettextFromC", "Gas consumption (CCR legs excluded):"));
else else
@ -1006,7 +1006,7 @@ bool enough_gas(int current_cylinder)
if (!cyl->start.mbar) if (!cyl->start.mbar)
return true; return true;
if (cyl->type.size.mliter) if (cyl->type.size.mliter)
return (float) (cyl->end.mbar - prefs.reserve_gas) * cyl->type.size.mliter / 1000.0 > (float) cyl->deco_gas_used.mliter; return (float)(cyl->end.mbar - prefs.reserve_gas) * cyl->type.size.mliter / 1000.0 > (float) cyl->deco_gas_used.mliter;
else else
return true; return true;
} }
@ -1089,7 +1089,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
transitiontime = depth / 75; /* this still needs to be made configurable */ transitiontime = depth / 75; /* this still needs to be made configurable */
plan_add_segment(diveplan, transitiontime, 0, current_cylinder, po2, false); plan_add_segment(diveplan, transitiontime, 0, current_cylinder, po2, false);
create_dive_from_plan(diveplan, is_planner); create_dive_from_plan(diveplan, is_planner);
return(false); return false;
} }
#if DEBUG_PLAN & 4 #if DEBUG_PLAN & 4
@ -1126,7 +1126,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
nuclear_regeneration(clock); nuclear_regeneration(clock);
vpmb_start_gradient(); vpmb_start_gradient();
if(decoMode() == RECREATIONAL) { if (decoMode() == RECREATIONAL) {
bool safety_stop = prefs.safetystop && max_depth >= 10000; bool safety_stop = prefs.safetystop && max_depth >= 10000;
track_ascent_gas(depth, &displayed_dive.cylinder[current_cylinder], avg_depth, bottom_time, safety_stop); track_ascent_gas(depth, &displayed_dive.cylinder[current_cylinder], avg_depth, bottom_time, safety_stop);
// How long can we stay at the current depth and still directly ascent to the surface? // How long can we stay at the current depth and still directly ascent to the surface?
@ -1177,7 +1177,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
free(stoplevels); free(stoplevels);
free(gaschanges); free(gaschanges);
return(false); return false;
} }
if (best_first_ascend_cylinder != current_cylinder) { if (best_first_ascend_cylinder != current_cylinder) {
@ -1354,7 +1354,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
this_decotimestep, po2, &displayed_dive, prefs.decosac); this_decotimestep, po2, &displayed_dive, prefs.decosac);
clock += this_decotimestep; clock += this_decotimestep;
/* Finish infinite deco */ /* Finish infinite deco */
if(clock >= 48 * 3600 && depth >= 6000) { if (clock >= 48 * 3600 && depth >= 6000) {
error = LONGDECO; error = LONGDECO;
break; break;
} }
@ -1402,9 +1402,9 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
} while (!is_final_plan); } while (!is_final_plan);
plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false); plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false);
if(decoMode() == VPMB) { if (decoMode() == VPMB) {
diveplan->eff_gfhigh = rint(100.0 * regressionb()); diveplan->eff_gfhigh = rint(100.0 * regressionb());
diveplan->eff_gflow = rint(100*(regressiona() * first_stop_depth + regressionb())); diveplan->eff_gflow = rint(100.0 * (regressiona() * first_stop_depth + regressionb()));
} }
create_dive_from_plan(diveplan, is_planner); create_dive_from_plan(diveplan, is_planner);
@ -1474,9 +1474,9 @@ int validate_gas(const char *text, struct gasmix *gas)
he = 0; he = 0;
text += strlen(translate("gettextFromC", "air")); text += strlen(translate("gettextFromC", "air"));
} else if (!strcasecmp(text, translate("gettextFromC", "oxygen"))) { } else if (!strcasecmp(text, translate("gettextFromC", "oxygen"))) {
o2 = 1000; o2 = 1000;
he = 0; he = 0;
text += strlen(translate("gettextFromC", "oxygen")); text += strlen(translate("gettextFromC", "oxygen"));
} else if (!strncasecmp(text, translate("gettextFromC", "ean"), 3)) { } else if (!strncasecmp(text, translate("gettextFromC", "ean"), 3)) {
o2 = get_permille(text + 3, &text); o2 = get_permille(text + 3, &text);
he = 0; he = 0;