From 73670ef281ed6f63c7b6759e68956a46d86d1df2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 26 Feb 2020 15:37:04 +1100 Subject: [PATCH] unix/unix_mphal: Adjust #if in mp_hal_stdin_rx_chr to improve format. --- ports/unix/unix_mphal.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c index 8fabb339d7..f7570a34af 100644 --- a/ports/unix/unix_mphal.c +++ b/ports/unix/unix_mphal.c @@ -147,7 +147,6 @@ static int call_dupterm_read(size_t idx) { #endif int mp_hal_stdin_rx_chr(void) { - unsigned char c; #if MICROPY_PY_OS_DUPTERM // TODO only support dupterm one slot at the moment if (MP_STATE_VM(dupterm_objs[0]) != MP_OBJ_NULL) { @@ -162,21 +161,20 @@ int mp_hal_stdin_rx_chr(void) { c = '\r'; } return c; - } else { - main_term:; -#endif - MP_THREAD_GIL_EXIT(); - int ret = read(0, &c, 1); - MP_THREAD_GIL_ENTER(); - if (ret == 0) { - c = 4; // EOF, ctrl-D - } else if (c == '\n') { - c = '\r'; - } - return c; -#if MICROPY_PY_OS_DUPTERM } +main_term:; #endif + + MP_THREAD_GIL_EXIT(); + unsigned char c; + int ret = read(0, &c, 1); + MP_THREAD_GIL_ENTER(); + if (ret == 0) { + c = 4; // EOF, ctrl-D + } else if (c == '\n') { + c = '\r'; + } + return c; } void mp_hal_stdout_tx_strn(const char *str, size_t len) {