]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: Start colouring subsys delimiter only after trailing blank
authorChris Down <chris@chrisdown.name>
Tue, 15 Feb 2022 13:39:57 +0000 (13:39 +0000)
committerChris Down <chris@chrisdown.name>
Tue, 15 Feb 2022 13:52:03 +0000 (13:52 +0000)
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 <chris@chrisdown.name>
sys-utils/dmesg.c

index 4606880ea6bfb18d57249755d6093fb00637183b..7cca88f2bb465a07c4d4db998415c73de99bce1a 100644 (file)
@@ -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;
                }
        }