From 7321bd91ad612cb5012184fa85d2078c7c28d91f Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Wed, 4 Feb 2015 21:30:59 +0800 Subject: [PATCH] vsprintf: Emit '\r' when printing '\n' Since putc() doesn't automatically print '\r' when '\n' is printed, we must manually do this conversion ourselves. Signed-off-by: Sean Cross --- vsprintf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vsprintf.c b/vsprintf.c index d28cf37..7662c76 100644 --- a/vsprintf.c +++ b/vsprintf.c @@ -532,7 +532,12 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt, str = buf; for (; *fmt ; ++fmt) { - if (*fmt != '%') { + if (*fmt == '\n') { + ADDCH(str, '\r'); + ADDCH(str, '\n'); + continue; + } + else if (*fmt != '%') { ADDCH(str, *fmt); continue; }