mirror of https://github.com/ipxe/ipxe.git
[libc] printf: support field width as an argument
Add support for the field width to be specified as an argument by using the '*' modifier. See the POSIX.1 specification for more details on conformance at http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html This change make the following calls equivalent: printf("%6s\n", "test"); printf("%*s\n", 6, "test"); Signed-off-by: Doug Goldstein <cardoe@cardoe.com>pull/60/head
parent
26050fd4c8
commit
a803c72c11
|
@ -218,7 +218,9 @@ size_t vcprintf ( struct printf_context *ctx, const char *fmt, va_list args ) {
|
|||
/* Process field width */
|
||||
width = 0;
|
||||
for ( ; ; fmt++ ) {
|
||||
if ( ( ( unsigned ) ( *fmt - '0' ) ) < 10 ) {
|
||||
if ( *fmt == '*' ) {
|
||||
width = va_arg(args, int);
|
||||
} else if ( ( ( unsigned ) ( *fmt - '0' ) ) < 10 ) {
|
||||
width = ( width * 10 ) + ( *fmt - '0' );
|
||||
} else {
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue