unix/mphalport.h: Fix build when MICROPY_USE_READLINE=0.
If the built-in input() is enabled (which it is by default) then it needs
some form of readline, so supply it with one when MICROPY_USE_READLINE=0.
Fixes issue
@@ -35,7 +35,21 @@ void mp_hal_set_interrupt_char(char c);
void mp_hal_stdio_mode_raw(void);
void mp_hal_stdio_mode_orig(void);
-#if MICROPY_USE_READLINE == 1 && MICROPY_PY_BUILTINS_INPUT
+#if MICROPY_PY_BUILTINS_INPUT && MICROPY_USE_READLINE == 0
+
+#include <malloc.h>
+#include "py/misc.h"
+#include "input.h"
+#define mp_hal_readline mp_hal_readline
+static inline int mp_hal_readline(vstr_t *vstr, const char *p) {
+ char *line = prompt((char*)p);
+ vstr_add_str(vstr, line);
+ free(line);
+ return 0;
+}
+
+#elif MICROPY_PY_BUILTINS_INPUT && MICROPY_USE_READLINE == 1
+
#include "py/misc.h"
#include "lib/mp-readline/readline.h"
// For built-in input() we need to wrap the standard readline() to enable raw mode
@@ -46,6 +60,7 @@ static inline int mp_hal_readline(vstr_t *vstr, const char *p) {
mp_hal_stdio_mode_orig();
return ret;
}
+
#endif
// TODO: POSIX et al. define usleep() as guaranteedly capable only of 1s sleep:
