From 7def6349d5df841d65c88720c5760963088db088 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 16 Sep 2017 15:33:30 +0200 Subject: [PATCH] bugfixes --- lib/log.c | 8 ++++++-- tests/unit/io.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/log.c b/lib/log.c index f20c29e49..3d700b3c8 100644 --- a/lib/log.c +++ b/lib/log.c @@ -118,7 +118,9 @@ static void log_resize(int signal, siginfo_t *sinfo, void *ctx) if (ret) return; - global_log->width = global_log->window.ws_col - 25 - strlenp(global_log->prefix); + global_log->width = global_log->window.ws_col - 25; + if (global_log->prefix) + global_log->width -= strlenp(global_log->prefix); debug(LOG_LOG | 15, "New terminal size: %dx%x", global_log->window.ws_row, global_log->window.ws_col); } @@ -161,7 +163,9 @@ int log_init(struct log *l, int level, long facilitites) l->window.ws_row = LOG_HEIGHT; } - l->width = l->window.ws_col - 25 - strlenp(l->prefix); + l->width = l->window.ws_col - 25; + if (l->prefix) + l->width -= strlenp(l->prefix); l->state = STATE_INITIALIZED; diff --git a/tests/unit/io.c b/tests/unit/io.c index 63fd26438..fc355efc4 100644 --- a/tests/unit/io.c +++ b/tests/unit/io.c @@ -170,7 +170,7 @@ ParameterizedTest(char *fmt, io, lowlevel) f = io_format_lookup(fmt); cr_assert_not_null(f, "Format '%s' does not exist", fmt); - ret = io_format_sprint(f, buf, sizeof(buf), &wbytes, smps, NUM_SAMPLES, SAMPLE_ALL); + ret = io_format_sprint(f, buf, sizeof(buf), &wbytes, smps, NUM_SAMPLES, SAMPLE_HAS_ALL); cr_assert_eq(ret, NUM_SAMPLES); ret = io_format_sscan(f, buf, wbytes, &rbytes, smpt, NUM_SAMPLES, 0); @@ -218,7 +218,7 @@ ParameterizedTest(char *fmt, io, highlevel) f = io_format_lookup(fmt); cr_assert_not_null(f, "Format '%s' does not exist", fmt); - ret = io_init(&io, f, SAMPLE_ALL); + ret = io_init(&io, f, SAMPLE_HAS_ALL); cr_assert_eq(ret, 0); ret = io_open(&io, fn);