From 14ecd17a9ad2a121c84619d472fcb772c0b05eaa Mon Sep 17 00:00:00 2001 From: night0721 Date: Sat, 2 Nov 2024 16:39:10 +0000 Subject: [PATCH] Make color print correctly after a line --- ccc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ccc.c b/ccc.c index 99f09ac..3539f52 100644 --- a/ccc.c +++ b/ccc.c @@ -976,6 +976,12 @@ void show_file_content() putchar('\n'); } + /* Check if the line ends with the ANSI reset sequence `\033[0m` */ + size_t len = strlen(buffer); + if (len >= 4 && strcmp(&buffer[len - 4], "\033[0m") == 0) { + /* Line ends with ANSI reset, print it */ + printf("\033[0m"); + } } fclose(stream); }