From cfba4bc61aac6eae1889bf8e8750f7b6a2ee393f Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 11 Nov 2016 23:20:05 +0200 Subject: 7549 Add support for %S to libstand as well so /boot/loader and friends can use it. Reviewed by: Robert Mustacchi Reviewed by: Adam Števko Approved by: Hans Rosenfeld MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/src/boot/lib/libstand/printf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'usr/src/boot/lib') diff --git a/usr/src/boot/lib/libstand/printf.c b/usr/src/boot/lib/libstand/printf.c index d91f705d75..c3e08a5b28 100644 --- a/usr/src/boot/lib/libstand/printf.c +++ b/usr/src/boot/lib/libstand/printf.c @@ -217,6 +217,7 @@ kvprintf(char const *fmt, kvprintf_fn_t *func, void *arg, int radix, va_list ap) char nbuf[MAXNBUF]; char *d; const char *p, *percent, *q; + uint16_t *S; u_char *up; int ch, n; uintmax_t num; @@ -411,6 +412,29 @@ reswitch: switch (ch = (u_char)*fmt++) { while (width--) PCHAR(padc); break; + case 'S': /* Assume console can cope with wide chars */ + S = va_arg(ap, uint16_t *); + if (S == NULL) + S = (uint16_t *)L"(null)"; + if (!dot) { + for (n = 0; S[n] != 0; n++) + continue; + } else { + for (n = 0; n < dwidth && S[n]; n++) + continue; + } + + width -= n; + + if (!ladjust && width > 0) + while (width--) + PCHAR(padc); + while (n--) + PCHAR(*S++); + if (ladjust && width > 0) + while (width--) + PCHAR(padc); + break; case 't': tflag = 1; goto reswitch; -- cgit v1.2.3