summaryrefslogtreecommitdiff
path: root/usr/src/boot/lib/libstand/printf.c
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2016-11-11 23:20:05 +0200
committerHans Rosenfeld <rosenfeld@grumpf.hope-2000.org>2017-01-10 23:02:43 +0100
commitcfba4bc61aac6eae1889bf8e8750f7b6a2ee393f (patch)
treec80189706e05c8b53c28137ad79de87cf3c41412 /usr/src/boot/lib/libstand/printf.c
parentcb214887258e20b89cd275946a280fee9c4b47fa (diff)
downloadillumos-gate-cfba4bc61aac6eae1889bf8e8750f7b6a2ee393f.tar.gz
7549 Add support for %S to libstand as well so /boot/loader and friends can use it.
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Adam Števko <adam.stevko@gmail.com> Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Diffstat (limited to 'usr/src/boot/lib/libstand/printf.c')
-rw-r--r--usr/src/boot/lib/libstand/printf.c24
1 files changed, 24 insertions, 0 deletions
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;