From 5fd8d6551cfee8de7c6718ed3b96d8cbc2ab995e Mon Sep 17 00:00:00 2001 From: Chris Down Date: Tue, 15 Feb 2022 13:39:57 +0000 Subject: [PATCH] dmesg: Start colouring subsys delimiter only after trailing blank This improves colouring when certain message levels are configured to display a background colour using terminal-colors.d. Previously the background colour starts at ":" on messages with a subsystem present, which looks pretty odd. Now it starts from the remaining message after the subsys (if there is one). If one only uses foreground colours, this largely makes no difference: the colon is now coloured with the same subsys colour, but there's no difference for the blank. Signed-off-by: Chris Down --- sys-utils/dmesg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 4606880ea6..7cca88f2bb 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -910,8 +910,8 @@ static const char *get_subsys_delimiter(const char *mesg, size_t mesg_size) return NULL; sz -= d - p + 1; if (sz) { - if (isblank(*(d + 1))) - return d; + if (sz >= 2 && isblank(*(d + 1))) + return d + 2; p = d + 1; } } -- 2.47.2