diff --git a/pycardium/patch.c b/pycardium/patch.c index 902653ec58450d7710ea2dffd5729ee9d22d89d9..bf85e5bd3d284425d80e966d68a1bbe88c2cafe0 100644 --- a/pycardium/patch.c +++ b/pycardium/patch.c @@ -49,8 +49,22 @@ int puts(const char *s) /* Used by mp_hal_move_cursor_back() */ int snprintf(char *str, size_t size, const char *format, ...) { - /* TODO: What should we do with this? */ - return -EIO; + /* + * There is one known place where snprintf is used: The + * mp_hal_move_cursor_back() function from mp-readline. + * This stub implementation just implements printf for + * that one case. + */ + if (format[0] != '\x1B' || size != 6) { + return -EIO; + } + + va_list ap; + va_start(ap, format); + printf("\x1B[%uD", va_arg(ap, unsigned int)); + va_end(ap); + + return -1; } /* Use by assert() */