summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-05-31 12:10:21 +1000
committerDamien George <damien@micropython.org>2023-05-31 16:08:44 +1000
commitb85611dae8ac13aa4c1eb37377a58cd77d04424e (patch)
treeff7d24a6acc08e5f39016ee1aee215ae45046ced
parented7a3b11d9a6c21a964d55ebfcdefeb392389d10 (diff)
downloadmicropython-b85611dae8ac13aa4c1eb37377a58cd77d04424e.tar.gz
micropython-b85611dae8ac13aa4c1eb37377a58cd77d04424e.zip
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>
-rw-r--r--shared/libc/printf.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/shared/libc/printf.c b/shared/libc/printf.c
index 6b5373188f..715181229e 100644
--- a/shared/libc/printf.c
+++ b/shared/libc/printf.c
@@ -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 {