From 00f2525d1a712c80c2f2b5ffa648e44fbc29ee05 Mon Sep 17 00:00:00 2001 From: Marco Paland Date: Mon, 24 Sep 2018 15:13:41 +0200 Subject: feat(printf): add # flag support for %b specifier Closes #29 --- printf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'printf.c') diff --git a/printf.c b/printf.c index e4cb328..d932dba 100644 --- a/printf.c +++ b/printf.c @@ -175,6 +175,9 @@ static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t ma if ((base == 16U) && (flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { buf[len++] = 'X'; } + if ((base == 2U) && (len < PRINTF_NTOA_BUFFER_SIZE)) { + buf[len++] = 'b'; + } if (len < PRINTF_NTOA_BUFFER_SIZE) { buf[len++] = '0'; } @@ -535,7 +538,6 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const } else if (*format == 'b') { base = 2U; - flags &= ~FLAGS_HASH; // no hash for bin format } else { base = 10U; -- cgit v1.2.3