diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-11-09 16:41:08 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-11-09 16:41:08 -0800 |
| commit | 355abc835ea75715b4dea38604ef64f8c4eeaa0f (patch) | |
| tree | 7e7c16e386157a42f686b27dbb6731738683befa /lib | |
| parent | 97bc95183d5114ce69c9387ebd2e2aa13feb65a7 (diff) | |
Fix output overflow and make help translatable
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils/stdout_helpers.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/utils/stdout_helpers.c b/lib/utils/stdout_helpers.c index 3de119757..4323e8a08 100644 --- a/lib/utils/stdout_helpers.c +++ b/lib/utils/stdout_helpers.c @@ -12,11 +12,21 @@ // Send "cooked" string of given length, where every occurrence of // LF character is replaced with CR LF. void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) { - while (len--) { - if (*str == '\n') { + bool last_cr = false; + while (len > 0) { + size_t i = 0; + if (str[0] == '\n' && !last_cr) { mp_hal_stdout_tx_strn("\r", 1); + i = 1; } - mp_hal_stdout_tx_strn(str++, 1); + // Lump all characters on the next line together. + while((last_cr || str[i] != '\n') && i < len) { + last_cr = str[i] == '\r'; + i++; + } + mp_hal_stdout_tx_strn(str, i); + str = &str[i]; + len -= i; } } |
