aboutsummaryrefslogtreecommitdiffstats
path: root/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'printf.c')
-rw-r--r--printf.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/printf.c b/printf.c
index 9d70faf..1770122 100644
--- a/printf.c
+++ b/printf.c
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////
// \author (c) Marco Paland (info@paland.com)
-// 2014-2018, PALANDesign Hannover, Germany
+// 2014-2019, PALANDesign Hannover, Germany
//
// \license The MIT License (MIT)
//
@@ -158,8 +158,7 @@ static inline void _out_fct(char character, void* buffer, size_t idx, size_t max
// internal secure strlen
-// \return The length of the string (excluding the terminating 0)
-// limited by 'max' size if non-zero
+// \return The length of the string (excluding the terminating 0) limited by 'maxsize'
static inline unsigned int _strnlen_s(const char* str, size_t maxsize)
{
const char* s;
@@ -389,11 +388,7 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
if (prec == 0U) {
diff = value - (double)whole;
- if (diff > 0.5) {
- // greater than 0.5, round up, e.g. 1.6 -> 2
- ++whole;
- }
- else if ((diff == 0.5) && (whole & 1)) {
+ if ((!(diff < 0.5) || (diff > 0.5)) && (whole & 1)) {
// exactly 0.5 and ODD, then round up
// 1.5 -> 2, but 2.5 -> 2
++whole;
@@ -776,7 +771,7 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
}
case 's' : {
- char* p = va_arg(va, char*);
+ const char* p = va_arg(va, char*);
unsigned int l = _strnlen_s(p, precision ? precision : (size_t)-1);
// pre padding
if (flags & FLAGS_PRECISION) {