diff options
| -rw-r--r-- | lib/vsprintf.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 926c7e00e2dc..f569feb7662e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -511,6 +511,16 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio | |||
| 511 | return buf; | 511 | return buf; |
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | static char *pointer(char *buf, char *end, void *ptr, int field_width, int precision, int flags) | ||
| 515 | { | ||
| 516 | flags |= SMALL; | ||
| 517 | if (field_width == -1) { | ||
| 518 | field_width = 2*sizeof(void *); | ||
| 519 | flags |= ZEROPAD; | ||
| 520 | } | ||
| 521 | return number(buf, end, (unsigned long) ptr, 16, field_width, precision, flags); | ||
| 522 | } | ||
| 523 | |||
| 514 | /** | 524 | /** |
| 515 | * vsnprintf - Format a string and place it in a buffer | 525 | * vsnprintf - Format a string and place it in a buffer |
| 516 | * @buf: The buffer to place the result into | 526 | * @buf: The buffer to place the result into |
| @@ -653,17 +663,9 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
| 653 | continue; | 663 | continue; |
| 654 | 664 | ||
| 655 | case 'p': | 665 | case 'p': |
| 656 | flags |= SMALL; | 666 | str = pointer(str, end, va_arg(args, void *), field_width, precision, flags); |
| 657 | if (field_width == -1) { | ||
| 658 | field_width = 2*sizeof(void *); | ||
| 659 | flags |= ZEROPAD; | ||
| 660 | } | ||
| 661 | str = number(str, end, | ||
| 662 | (unsigned long) va_arg(args, void *), | ||
| 663 | 16, field_width, precision, flags); | ||
| 664 | continue; | 667 | continue; |
| 665 | 668 | ||
| 666 | |||
| 667 | case 'n': | 669 | case 'n': |
| 668 | /* FIXME: | 670 | /* FIXME: |
| 669 | * What does C99 say about the overflow case here? */ | 671 | * What does C99 say about the overflow case here? */ |
