Skip to content

Commit

Permalink
Added extra encoded character support (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
AsparagusEduardo authored Nov 25, 2024
1 parent 6560bba commit 4beb0ef
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/mini_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4beb0ef

Please sign in to comment.