rework #4

Merged
Steins7 merged 88 commits from rework into dev 2024-04-20 18:20:23 +00:00
Showing only changes of commit 254fec4f00 - Show all commits

View File

@ -21,7 +21,7 @@ static uint32_t buffer_write(uint8_t byte, void* arg);
static uint32_t render_format(FormatCallback callback, void* arg, static uint32_t render_format(FormatCallback callback, void* arg,
const char* restrict format, va_list va); const char* restrict format, va_list va);
static uint32_t render_signed(FormatCallback callback, void* arg, static uint32_t render_signed(FormatCallback callback, void* arg,
int32_t number, uint8_t base, uint8_t width, bool zero_padding); int32_t number, uint8_t base, uint8_t width);
static uint32_t render_unsigned(FormatCallback callback, void* arg, static uint32_t render_unsigned(FormatCallback callback, void* arg,
uint32_t number, uint8_t base, uint8_t width, bool zero_padding); uint32_t number, uint8_t base, uint8_t width, bool zero_padding);
@ -100,7 +100,7 @@ static uint32_t render_format(FormatCallback callback, void* arg,
break; break;
case 'i': case 'i':
if (render_signed(callback, arg, va_arg(va, int32_t), if (render_signed(callback, arg, va_arg(va, int32_t),
10, width, zero_padding)) { 10, width)) {
return 1; return 1;
} }
break; break;
@ -158,7 +158,7 @@ static uint32_t render_format(FormatCallback callback, void* arg,
} }
static uint32_t render_signed(FormatCallback callback, void* arg, static uint32_t render_signed(FormatCallback callback, void* arg,
int32_t number, uint8_t base, uint8_t width, bool zero_padding) int32_t number, uint8_t base, uint8_t width)
{ {
if (width > 0 && number < 0) { if (width > 0 && number < 0) {
--width; --width;
@ -183,21 +183,16 @@ static uint32_t render_signed(FormatCallback callback, void* arg,
while (width > 0) { while (width > 0) {
--width; --width;
if (zero_padding) {
if (callback('0', arg)) return 1;
} else {
if (callback(' ', arg)) return 1; if (callback(' ', arg)) return 1;
} }
} }
}
if (number < 0) { if (number < 0) {
callback('-', arg); callback('-', arg);
number = -number; number = -number;
} }
return render_unsigned(callback, arg, (uint32_t)number, base, 0, return render_unsigned(callback, arg, (uint32_t)number, base, 0, false);
zero_padding);
} }
static uint32_t render_unsigned(FormatCallback callback, void* arg, static uint32_t render_unsigned(FormatCallback callback, void* arg,