printk: Add padding support to string format specifiers
The numeric format specifiers already have this support, but strings didn't. This makes it possible to add padding after strings, using format specifiers such as %-10s. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
75250f4747
commit
7d71c0656f
|
@ -190,9 +190,17 @@ void _vprintk(out_func_t out, void *ctx, const char *fmt, va_list ap)
|
|||
}
|
||||
case 's': {
|
||||
char *s = va_arg(ap, char *);
|
||||
char *start = s;
|
||||
|
||||
while (*s)
|
||||
out((int)(*s++), ctx);
|
||||
|
||||
if (padding == PAD_SPACE_AFTER) {
|
||||
int remaining = min_width - (s - start);
|
||||
while (remaining-- > 0) {
|
||||
out(' ', ctx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'c': {
|
||||
|
|
Loading…
Reference in a new issue