Message ID | 20200423101955.13761-3-wipawel@amazon.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Small fixes and improvements | expand |
diff --git a/common/libc/vsnprintf.c b/common/libc/vsnprintf.c index a49fd30..b9a4fab 100644 --- a/common/libc/vsnprintf.c +++ b/common/libc/vsnprintf.c @@ -284,7 +284,17 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) /* Put regular characters into the destination. */ if ( *fmt != '%' ) { + /* + * The '\n' character alone on some terminals is not automatically + * converted to CRLF. + * The explicit CRLF sequence guarantees proper line by line + * formatting in the output. + */ + if ( *fmt == '\n' && str < end ) + PUT('\r'); + PUT(*fmt); + continue; }
The explicit LFCR sequence guarantees proper line by line formatting in the output. The '\n' character alone on some terminals is not automatically converted to LFCR. Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> --- Changed since v1: * Emit CRLF instead of LFCR common/libc/vsnprintf.c | 10 ++++++++++ 1 file changed, 10 insertions(+)