From 51e4f85905305db1acd0a8b9a4cf94244bb382f1 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 12 May 2021 11:10:41 -0400 Subject: [PATCH] Fix #1002, remove extra newlines in utassert logs If messages (e.g. from UtPrintf, etc) already have a newline, do not add another. --- ut_assert/src/utbsp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ut_assert/src/utbsp.c b/ut_assert/src/utbsp.c index d5f1b1d1b..fde612fe4 100644 --- a/ut_assert/src/utbsp.c +++ b/ut_assert/src/utbsp.c @@ -108,6 +108,7 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage) { const char *Prefix; char Buffer[16]; + size_t MsgLen; uint32 TermModeBits = OS_BSP_CONSOLEMODE_NORMAL; uint32 MsgEnabled = BSP_UT_Global.CurrVerbosity >> MessageType; @@ -182,8 +183,12 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage) } OS_BSP_ConsoleOutput_Impl(" ", 1); - OS_BSP_ConsoleOutput_Impl(OutputMessage, strlen(OutputMessage)); - OS_BSP_ConsoleOutput_Impl("\n", 1); + MsgLen = strlen(OutputMessage); + OS_BSP_ConsoleOutput_Impl(OutputMessage, MsgLen); + if (MsgLen == 0 || OutputMessage[MsgLen - 1] != '\n') + { + OS_BSP_ConsoleOutput_Impl("\n", 1); + } OS_BSP_Unlock_Impl(); }