Skip to content

Commit 73670ef

Browse files
committed
unix/unix_mphal: Adjust #if in mp_hal_stdin_rx_chr to improve format.
1 parent a642241 commit 73670ef

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

ports/unix/unix_mphal.c

+12-14
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ static int call_dupterm_read(size_t idx) {
147147
#endif
148148

149149
int mp_hal_stdin_rx_chr(void) {
150-
unsigned char c;
151150
#if MICROPY_PY_OS_DUPTERM
152151
// TODO only support dupterm one slot at the moment
153152
if (MP_STATE_VM(dupterm_objs[0]) != MP_OBJ_NULL) {
@@ -162,21 +161,20 @@ int mp_hal_stdin_rx_chr(void) {
162161
c = '\r';
163162
}
164163
return c;
165-
} else {
166-
main_term:;
167-
#endif
168-
MP_THREAD_GIL_EXIT();
169-
int ret = read(0, &c, 1);
170-
MP_THREAD_GIL_ENTER();
171-
if (ret == 0) {
172-
c = 4; // EOF, ctrl-D
173-
} else if (c == '\n') {
174-
c = '\r';
175-
}
176-
return c;
177-
#if MICROPY_PY_OS_DUPTERM
178164
}
165+
main_term:;
179166
#endif
167+
168+
MP_THREAD_GIL_EXIT();
169+
unsigned char c;
170+
int ret = read(0, &c, 1);
171+
MP_THREAD_GIL_ENTER();
172+
if (ret == 0) {
173+
c = 4; // EOF, ctrl-D
174+
} else if (c == '\n') {
175+
c = '\r';
176+
}
177+
return c;
180178
}
181179

182180
void mp_hal_stdout_tx_strn(const char *str, size_t len) {

0 commit comments

Comments
 (0)