From 3b959c05ffe2173bf0fb22ca0d3dd6461d12f173 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 20 Mar 2019 07:13:02 +0000 Subject: Bit more logging to show drawing errors. --- format-draw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/format-draw.c b/format-draw.c index a3bd4351..84af1145 100644 --- a/format-draw.c +++ b/format-draw.c @@ -527,6 +527,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, style_set(&sy, base); TAILQ_INIT(&frs); + log_debug("%s: %s", __func__, expanded); /* * We build three screens for left, right, centre alignment, one for @@ -574,10 +575,13 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, /* This is a style. Work out where the end is and parse it. */ end = format_skip(cp + 2, "]"); - if (end == NULL) + if (end == NULL) { + log_debug("no terminating ] at '%s'", cp + 2); return; + } tmp = xstrndup(cp + 2, end - (cp + 2)); if (style_parse(&sy, base, tmp) != 0) { + log_debug("invalid style '%s'", tmp); free(tmp); return; } -- cgit v1.2.3 From ae46a19b8e2bafd7c3fc5cba99b9f430c8cf9b1c Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 20 Mar 2019 07:24:03 +0000 Subject: Ignore invalid styles rather than throwing away the whole format, this matches what we used to do. --- format-draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/format-draw.c b/format-draw.c index 84af1145..40ba27bf 100644 --- a/format-draw.c +++ b/format-draw.c @@ -583,7 +583,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, if (style_parse(&sy, base, tmp) != 0) { log_debug("invalid style '%s'", tmp); free(tmp); - return; + cp = end + 1; + continue; } log_debug("style '%s' -> '%s'", tmp, style_tostring(&sy)); free(tmp); -- cgit v1.2.3 From 458b87150b3fe989bb3d5d611f1d010a71839117 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 20 Mar 2019 07:28:31 +0000 Subject: Do not leak ranges on error. --- format-draw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/format-draw.c b/format-draw.c index 40ba27bf..ed50236f 100644 --- a/format-draw.c +++ b/format-draw.c @@ -577,7 +577,9 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, end = format_skip(cp + 2, "]"); if (end == NULL) { log_debug("no terminating ] at '%s'", cp + 2); - return; + TAILQ_FOREACH_SAFE(fr, &frs, entry, fr1) + format_free_range(&frs, fr); + goto out; } tmp = xstrndup(cp + 2, end - (cp + 2)); if (style_parse(&sy, base, tmp) != 0) { @@ -755,6 +757,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, format_free_range(&frs, fr); } +out: /* Free the screens. */ for (i = 0; i < TOTAL; i++) screen_free(&s[i]); -- cgit v1.2.3 From ed962e76129d499012bee92617620d3703245482 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 20 Mar 2019 07:30:05 +0000 Subject: Include function name in logging. --- format-draw.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/format-draw.c b/format-draw.c index ed50236f..dd03435c 100644 --- a/format-draw.c +++ b/format-draw.c @@ -576,19 +576,21 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, /* This is a style. Work out where the end is and parse it. */ end = format_skip(cp + 2, "]"); if (end == NULL) { - log_debug("no terminating ] at '%s'", cp + 2); + log_debug("%s: no terminating ] at '%s'", __func__, + cp + 2); TAILQ_FOREACH_SAFE(fr, &frs, entry, fr1) format_free_range(&frs, fr); goto out; } tmp = xstrndup(cp + 2, end - (cp + 2)); if (style_parse(&sy, base, tmp) != 0) { - log_debug("invalid style '%s'", tmp); + log_debug("%s: invalid style '%s'", __func__, tmp); free(tmp); cp = end + 1; continue; } - log_debug("style '%s' -> '%s'", tmp, style_tostring(&sy)); + log_debug("%s: style '%s' -> '%s'", __func__, tmp, + style_tostring(&sy)); free(tmp); /* Check the list state. */ @@ -706,7 +708,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base, log_debug("%s: width %s is %u", __func__, names[i], width[i]); } if (focus_start != -1 && focus_end != -1) - log_debug("focus is %d-%d", focus_start, focus_end); + log_debug("%s: focus %d-%d", __func__, focus_start, focus_end); TAILQ_FOREACH(fr, &frs, entry) { log_debug("%s: range %d|%u is %s %u-%u", __func__, fr->type, fr->argument, names[fr->index], fr->start, fr->end); -- cgit v1.2.3