gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 343687c4a94df73e02dcd44a604d84775ff39655 parent 31416804fc1dde56a456bab3b0eb002d098ddfac Author: Toxa <56631470+untoxa@users.noreply.github.com> Date: Sun, 14 Feb 2021 10:51:51 +0300 Merge pull request #135 from bbbbbr/develop_printf_options printf: try not to fail when encountering %0... %1-9... and upper case %X Diffstat:
| M | gbdk-lib/libc/sprintf.c | 12 | +++++++++++- |
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/gbdk-lib/libc/sprintf.c b/gbdk-lib/libc/sprintf.c @@ -31,9 +31,18 @@ void __printf(const char *format, emitter_t emitter, char **pData, va_list va) char buf[16]; while (*format) { if (*format == '%') { - switch (*++format) { + format++; + + // 0 Padding is not supported, ignore + if (*format == '0') format++; + + // Width Specifier is not supported, ignore 1 digit worth + if ((*format >= '1') && (*format <= '9')) format++; + + switch (*format) { case 'h': { switch (*++format) { + case 'X' : case 'x' : { _printhexbyte(va_arg(va, char), emitter, pData); break; @@ -70,6 +79,7 @@ void __printf(const char *format, emitter_t emitter, char **pData, va_list va) _printbuf(buf, emitter, pData); break; } + case 'X': case 'x': { _printhex(va_arg(va, int), emitter, pData);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.