From 014b62ab265e75c283fc455e9bef936131cadb41 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Thu, 5 Feb 2015 11:31:53 +0800 Subject: [PATCH] bionic: Have putchar() put \r if \n is printed Since putchar() is only called by printf() (as opposed to the lower- level serial_putc()), we can have it nicely format the output by adding \r when \n is printed. To get the old behavior back, call serial_putc() directly. This fixes gcc's optimization when calling: printf("\n") As this will get silently turned into a call to putchar('\n') Signed-off-by: Sean Cross --- bionic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bionic.c b/bionic.c index c9e4c82..e13f79a 100644 --- a/bionic.c +++ b/bionic.c @@ -345,13 +345,14 @@ void _msleep(uint32_t msecs) int puts(const char *str) { serial_puts(str); - serial_putc('\r'); serial_putc('\n'); return 1; } int putchar(int c) { + if (c == '\n') + serial_putc('\r'); serial_putc(c); return c; }