mirror of
git://git.suckless.org/sbase
synced 2024-12-21 22:50:16 +00:00
printf: allow flags for the %s format string aswell
This is useful for example to left-align strings and pad them with spaces. printf '%-12.12s: %s\n' 'user' "$USER"
This commit is contained in:
parent
61be841f5c
commit
1cc5a57fd7
6
printf.c
6
printf.c
@ -127,7 +127,11 @@ main(int argc, char *argv[])
|
||||
free(rarg);
|
||||
break;
|
||||
case 's':
|
||||
printf("%*.*s", width, precision, arg);
|
||||
fmt = estrdup(flag ? "%#*.*s" : "%*.*s");
|
||||
if (flag)
|
||||
fmt[1] = flag;
|
||||
printf(fmt, width, precision, arg);
|
||||
free(fmt);
|
||||
break;
|
||||
case 'd': case 'i': case 'o': case 'u': case 'x': case 'X':
|
||||
for (j = 0; isspace(arg[j]); j++);
|
||||
|
Loading…
Reference in New Issue
Block a user