028-fix-printf-regression-with-alt-form-octal-zero-flag-and-field-width.patch 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. From 78897b0dc00b7cd5c29af5e0b7eebf2396d8dce0 Mon Sep 17 00:00:00 2001
  2. From: Rich Felker <[email protected]>
  3. Date: Fri, 16 Sep 2016 17:40:08 -0400
  4. Subject: fix printf regression with alt-form octal, zero flag, and field width
  5. commit b91cdbe2bc8b626aa04dc6e3e84345accf34e4b1, in fixing another
  6. issue, changed the logic for how alt-form octal adds the leading zero
  7. to adjust the precision rather than using a prefix character. this
  8. wrongly suppressed the zero flag by mimicing an explicit precision
  9. given by the format string. switch back to using a prefix character.
  10. based on bug report and patch by Dmitry V. Levin, but simplified.
  11. ---
  12. src/stdio/vfprintf.c | 2 +-
  13. 1 file changed, 1 insertion(+), 1 deletion(-)
  14. diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
  15. index 2ecf769..e439a07 100644
  16. --- a/src/stdio/vfprintf.c
  17. +++ b/src/stdio/vfprintf.c
  18. @@ -570,7 +570,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
  19. if (0) {
  20. case 'o':
  21. a = fmt_o(arg.i, z);
  22. - if ((fl&ALT_FORM) && p<z-a+1) p=z-a+1;
  23. + if ((fl&ALT_FORM) && p<z-a+1) prefix+=5, pl=1;
  24. } if (0) {
  25. case 'd': case 'i':
  26. pl=1;
  27. --
  28. cgit v0.11.2