From 8180797aa79b0d63769afe26abf90fe5943491fb Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 18 Mar 2013 14:22:48 +0100 Subject: [PATCH] Support field widths in %c printf conversion. --- libc/format.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libc/format.cpp b/libc/format.cpp index 300ae958..243166ce 100644 --- a/libc/format.cpp +++ b/libc/format.cpp @@ -23,7 +23,7 @@ *******************************************************************************/ // Number of bugs seemingly unrelated bugs that have been traced to here: -// Countless + 1 +// Countless + 2 #include #include @@ -510,8 +510,12 @@ extern "C" size_t vprintf_callback(size_t (*callback)(void*, const char*, size_t case CHARACTER: { int c = va_arg(parameters, int); + size_t len = 1; + size_t chars = len; + if ( prepend_chars && chars < field_width ) { REPEAT_BLANKS(field_width - chars); } if ( READY_SIZE <= readylen ) { READY_FLUSH(); } ready[readylen++] = c; + if ( append_chars && chars < field_width ) { REPEAT_BLANKS(field_width - chars); } break; } }