%c printing repetition fixed

This commit is contained in:
Wiesner András 2023-09-05 13:40:55 +02:00
parent c1512cde98
commit 4d03fb11c9

View File

@ -337,7 +337,7 @@ static int pfn_double(va_list *va, FmtWord *fmt, char *outbuf, size_t free_space
// print character
static int pfn_char(va_list *va, FmtWord *fmt, char *outbuf, size_t free_space) {
int c = va_arg((*va), int);
unsigned rep = (fmt->width == 0) ? 1 : fmt->width; // determine repetition count
unsigned rep = (fmt->width <= 0) ? 1 : fmt->width; // determine repetition count
rep = MIN(free_space, rep);
for (unsigned i = 0; i < rep; i++) {
outbuf[i] = (char)c;