summaryrefslogtreecommitdiff
path: root/lib/printf
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-03-26 17:58:54 +0100
committerDavid Lamparter <equinox@diac24.net>2021-03-30 22:32:59 +0200
commit2d9a4e2931e4f20c6bc49b09956a1e350664e3f2 (patch)
treee7b0703a18ccc7c4cf657a81de23dc559618c3dd /lib/printf
parent3ea794305960ed9fca230c3e0f8b1b73c2915101 (diff)
lib: allow discerning unspec width in printfrr ext
With 0 currently the default value for the width specifier, it's not possible to discern that from a %*p where 0 was passed as the length parameter. Use -1 to allow for that. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/printf')
-rw-r--r--lib/printf/vfprintf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/printf/vfprintf.c b/lib/printf/vfprintf.c
index 7fafa89aa7..1bd24743ee 100644
--- a/lib/printf/vfprintf.c
+++ b/lib/printf/vfprintf.c
@@ -305,7 +305,7 @@ vbprintfrr(struct fbuf *cb_in, const char *fmt0, va_list ap)
flags = 0;
dprec = 0;
- width = 0;
+ width = -1;
prec = -1;
sign = '\0';
ox[1] = '\0';
@@ -688,6 +688,9 @@ number: if ((dprec = prec) >= 0)
* Compute actual size, so we know how much to pad.
* size excludes decimal prec; realsz includes it.
*/
+ if (width < 0)
+ width = 0;
+
realsz = dprec > size ? dprec : size;
if (sign)
realsz++;
@@ -750,6 +753,9 @@ ext_printed:
* Keep analogous to code above please.
*/
+ if (width < 0)
+ width = 0;
+
realsz = size;
prsize = width > realsz ? width : realsz;
if ((unsigned int)ret + prsize > INT_MAX) {