debug #2
15
srv/format.c
15
srv/format.c
@ -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,11 +183,7 @@ static uint32_t render_signed(FormatCallback callback, void* arg,
|
|||||||
|
|
||||||
while (width > 0) {
|
while (width > 0) {
|
||||||
--width;
|
--width;
|
||||||
if (zero_padding) {
|
if (callback(' ', arg)) return 1;
|
||||||
if (callback('0', arg)) return 1;
|
|
||||||
} else {
|
|
||||||
if (callback(' ', arg)) return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +192,7 @@ static uint32_t render_signed(FormatCallback callback, void* 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,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user