mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-25 09:05:47 -04:00
config: let value_to_double() log errors
This commit is contained in:
parent
def2d80b0a
commit
328b53b166
1 changed files with 14 additions and 13 deletions
27
config.c
27
config.c
|
|
@ -501,7 +501,12 @@ value_to_double(struct context *ctx, double *res)
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
|
||||||
*res = strtod(s, &end);
|
*res = strtod(s, &end);
|
||||||
return errno == 0 && *end == '\0';
|
if (!(errno == 0 && *end == '\0')) {
|
||||||
|
LOG_CONTEXTUAL_ERR("invalid decimal value");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool NOINLINE
|
static bool NOINLINE
|
||||||
|
|
@ -590,10 +595,8 @@ value_to_pt_or_px(struct context *ctx, struct pt_or_px *res)
|
||||||
res->px = value;
|
res->px = value;
|
||||||
} else {
|
} else {
|
||||||
double value;
|
double value;
|
||||||
if (!value_to_double(ctx, &value)) {
|
if (!value_to_double(ctx, &value))
|
||||||
LOG_CONTEXTUAL_ERR("invalid decimal value");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
res->pt = value;
|
res->pt = value;
|
||||||
res->px = 0;
|
res->px = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1130,11 +1133,8 @@ parse_section_scrollback(struct context *ctx)
|
||||||
|
|
||||||
else if (strcmp(key, "multiplier") == 0) {
|
else if (strcmp(key, "multiplier") == 0) {
|
||||||
double multiplier;
|
double multiplier;
|
||||||
if (!value_to_double(ctx, &multiplier)) {
|
if (!value_to_double(ctx, &multiplier))
|
||||||
LOG_CONTEXTUAL_ERR("invalid decimal value");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
conf->scrollback.multiplier = multiplier;
|
conf->scrollback.multiplier = multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1324,8 +1324,11 @@ parse_section_colors(struct context *ctx)
|
||||||
|
|
||||||
else if (strcmp(key, "alpha") == 0) {
|
else if (strcmp(key, "alpha") == 0) {
|
||||||
double alpha;
|
double alpha;
|
||||||
if (!value_to_double(ctx, &alpha) || alpha < 0. || alpha > 1.) {
|
if (!value_to_double(ctx, &alpha))
|
||||||
LOG_CONTEXTUAL_ERR("invalid decimal value, or not in range 0.0-1.0");
|
return false;
|
||||||
|
|
||||||
|
if (alpha < 0. || alpha > 1.) {
|
||||||
|
LOG_CONTEXTUAL_ERR("not in range 0.0-1.0");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2429,10 +2432,8 @@ parse_section_tweak(struct context *ctx)
|
||||||
|
|
||||||
else if (strcmp(key, "box-drawing-base-thickness") == 0) {
|
else if (strcmp(key, "box-drawing-base-thickness") == 0) {
|
||||||
double base_thickness;
|
double base_thickness;
|
||||||
if (!value_to_double(ctx, &base_thickness)) {
|
if (!value_to_double(ctx, &base_thickness))
|
||||||
LOG_CONTEXTUAL_ERR("invalid decimal value");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
conf->tweak.box_drawing_base_thickness = base_thickness;
|
conf->tweak.box_drawing_base_thickness = base_thickness;
|
||||||
LOG_WARN("tweak: box-drawing-base-thickness=%f",
|
LOG_WARN("tweak: box-drawing-base-thickness=%f",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue