From 81a4f21f1be5ff814b8e1fad3ab600071c61dfa3 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Tue, 7 Mar 2023 18:41:14 +0800 Subject: [PATCH] libc/libvsprintf: use puts to replace the putc Signed-off-by: yinshengkai --- libs/libc/stdio/lib_libvsprintf.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c index c0481c6272..b0f8b74e7f 100644 --- a/libs/libc/stdio/lib_libvsprintf.c +++ b/libs/libc/stdio/lib_libvsprintf.c @@ -68,6 +68,8 @@ #endif #define stream_putc(c,stream) (total_len++, lib_stream_putc(stream, c)) +#define stream_puts(buf, len, stream) \ + (total_len += len, lib_stream_puts(stream, buf, len)) /* Order is relevant here and matches order in format string */ @@ -947,16 +949,9 @@ str_lpad: } } - while (size) - { - stream_putc(*pnt++, stream); - if (width != 0) - { - width -= 1; - } - - size -= 1; - } + stream_puts(pnt, size, stream); + width = width >= size ? width - size : 0; + size = 0; goto tail; }