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 <xobs@kosagi.com>
This commit is contained in:
Sean Cross 2015-02-05 11:31:53 +08:00
parent 1023337c61
commit 014b62ab26

View file

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