print: improve padding
This commit is contained in:
parent
f621403d8f
commit
b5cc93bfc0
13
lib/print.c
13
lib/print.c
|
@ -241,16 +241,15 @@ static size_t vsnprintf(char** str, size_t* size, const char *format, va_list va
|
|||
// check padding
|
||||
if ('0'==*format) { // padding required
|
||||
format++; // go to padding number
|
||||
padding = 0;
|
||||
while (*format>='0' && *format<='9') {
|
||||
padding *= 10; // shift padding digit
|
||||
padding += *format-'0'; // get next padding digit
|
||||
format++; // go to next character
|
||||
}
|
||||
if (0==*format) { // end of string detected
|
||||
goto end;
|
||||
}
|
||||
if (*format>='0' && *format<='9') {
|
||||
padding = *format-'0';
|
||||
format++; // go to format specifier
|
||||
if (0==*format) { // end of string detected
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check format specifier
|
||||
switch (*format) {
|
||||
|
|
Loading…
Reference in New Issue