From 4beb0efbcc202048fafa606147b7b5243ed55951 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 24 Nov 2024 22:46:01 -0300 Subject: [PATCH] Added extra encoded character support (#2050) --- src/mini_printf.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/mini_printf.c b/src/mini_printf.c index ac8a0ef12774..e4b893724284 100644 --- a/src/mini_printf.c +++ b/src/mini_printf.c @@ -86,6 +86,8 @@ static inline char mini_pchar_decode(char encoded) ret = '('; // opening parentheses else if (encoded == CHAR_RIGHT_PAREN) ret = ')'; // closing parentheses + else if (encoded == CHAR_HYPHEN) + ret = '-'; // hyphen return ret; } @@ -133,7 +135,31 @@ static s32 _putsEncoded(char *s, s32 len, void *buf) { break; } - *(b->pbuffer ++) = mini_pchar_decode(s[i]); + if (s[i] == CHAR_NEWLINE) + { + *(b->pbuffer ++) = '\\'; + *(b->pbuffer ++) = 'n'; + } + else if (s[i] == CHAR_PROMPT_SCROLL) + { + *(b->pbuffer ++) = '\\'; + *(b->pbuffer ++) = 'l'; + } + else if (s[i] == CHAR_PROMPT_CLEAR) + { + *(b->pbuffer ++) = '\\'; + *(b->pbuffer ++) = 'p'; + } + else if (s[i] == CHAR_ELLIPSIS) + { + *(b->pbuffer ++) = '.'; + *(b->pbuffer ++) = '.'; + *(b->pbuffer ++) = '.'; + } + else + { + *(b->pbuffer ++) = mini_pchar_decode(s[i]); + } } *(b->pbuffer) = 0; return b->pbuffer - p0;