From f048d50953a9ff661d980784d025fd6d8024cee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 27 Oct 2004 12:47:16 +0000 Subject: [PATCH] Padding was broken for strings and characters since the move to vsnprintf(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9529 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/stdio/kernel_vsprintf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kernel/libroot/posix/stdio/kernel_vsprintf.c b/src/kernel/libroot/posix/stdio/kernel_vsprintf.c index a1af30e6c4..a2587b3b87 100644 --- a/src/kernel/libroot/posix/stdio/kernel_vsprintf.c +++ b/src/kernel/libroot/posix/stdio/kernel_vsprintf.c @@ -285,12 +285,12 @@ vsnprintf(char *buffer, size_t bufferSize, const char *format, va_list args) switch (format[0]) { case 'c': - if (!(flags & LEFT) && !put_padding(&string, &bytesLeft, fieldWidth)) + if (!(flags & LEFT) && !put_padding(&string, &bytesLeft, fieldWidth - 1)) goto out; put_character(&string, &bytesLeft, (char)va_arg(args, int)); - if ((flags & LEFT) != 0 && !put_padding(&string, &bytesLeft, fieldWidth)) + if ((flags & LEFT) != 0 && !put_padding(&string, &bytesLeft, fieldWidth - 1)) goto out; continue; @@ -303,6 +303,7 @@ vsnprintf(char *buffer, size_t bufferSize, const char *format, va_list args) argument = ""; length = strnlen(argument, precision); + fieldWidth -= length; if (!(flags & LEFT) && !put_padding(&string, &bytesLeft, fieldWidth)) goto out;