aboutsummaryrefslogtreecommitdiffstats
path: root/printf.c
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-09-14 15:02:57 +0200
committerMarco Paland <marco@paland.com>2018-09-14 15:02:57 +0200
commit21a282a2a427cb33d12d1d31ae8aee14d9bbb8c3 (patch)
tree03e56c130318d2cb9398213c43b1d961495a722f /printf.c
parent7075d314a0875caa45c8571f7aa52f732f3612a9 (diff)
downloadprintf-21a282a2a427cb33d12d1d31ae8aee14d9bbb8c3.tar.gz
printf-21a282a2a427cb33d12d1d31ae8aee14d9bbb8c3.tar.bz2
printf-21a282a2a427cb33d12d1d31ae8aee14d9bbb8c3.zip
fix(printf): ignore 0 flag for integers if precision is specified
Fixes #27
Diffstat (limited to 'printf.c')
-rw-r--r--printf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/printf.c b/printf.c
index 9ef669f..a7a3d68 100644
--- a/printf.c
+++ b/printf.c
@@ -551,6 +551,11 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
flags &= ~(FLAGS_PLUS | FLAGS_SPACE);
}
+ // ignore '0' flag when precision is given
+ if (flags & FLAGS_PRECISION) {
+ flags &= ~FLAGS_ZEROPAD;
+ }
+
// convert the integer
if ((*format == 'i') || (*format == 'd')) {
// signed