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 <xobs@kosagi.com>
This commit is contained in:
Sean Cross 2015-02-04 21:30:59 +08:00
parent 0bfdbb314f
commit 7321bd91ad

View file

@ -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;
}