shared/libc/printf: Fix stdout destination for putchar and puts.
These functions should output to the same location as printf in this file. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
ed7a3b11d9
commit
b85611dae8
|
@ -72,16 +72,14 @@ int vprintf(const char *fmt, va_list ap) {
|
|||
// need this because gcc optimises printf("%c", c) -> putchar(c), and printf("a") -> putchar('a')
|
||||
int putchar(int c) {
|
||||
char chr = c;
|
||||
mp_hal_stdout_tx_strn_cooked(&chr, 1);
|
||||
MICROPY_INTERNAL_PRINTF_PRINTER->print_strn(MICROPY_INTERNAL_PRINTF_PRINTER->data, &chr, 1);
|
||||
return chr;
|
||||
}
|
||||
|
||||
// need this because gcc optimises printf("string\n") -> puts("string")
|
||||
int puts(const char *s) {
|
||||
mp_hal_stdout_tx_strn_cooked(s, strlen(s));
|
||||
char chr = '\n';
|
||||
mp_hal_stdout_tx_strn_cooked(&chr, 1);
|
||||
return 1;
|
||||
MICROPY_INTERNAL_PRINTF_PRINTER->print_strn(MICROPY_INTERNAL_PRINTF_PRINTER->data, s, strlen(s));
|
||||
return putchar('\n'); // will return 10, which is >0 per specs of puts
|
||||
}
|
||||
|
||||
typedef struct _strn_print_env_t {
|
||||
|
|
Loading…
Reference in New Issue