From fea5386d6de4f7c76208aee9f54e4f547cdd6a8a Mon Sep 17 00:00:00 2001 From: Julian Barathieu Date: Tue, 12 Mar 2019 17:41:14 +0100 Subject: [PATCH] sprintf stuff --- kaleid/crtlib/sprintf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kaleid/crtlib/sprintf.c b/kaleid/crtlib/sprintf.c index 8174ddd..be93623 100644 --- a/kaleid/crtlib/sprintf.c +++ b/kaleid/crtlib/sprintf.c @@ -71,7 +71,7 @@ size_t snprintf(char *str, size_t n, const char *fmt, ...) } // Size of the buffer is for convertions -#define CONVBUF 4096 +#define CONVBUF 64 size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) { @@ -82,10 +82,13 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) char mod; char convbuf[CONVBUF] = { 0 }; - char c; - int d; - uint u; - char *s; + char c, *s; + int d; + uint u; + + assert(str && fmt); + + if (n == 0) return 0; // For aesthetic reasons... n--; @@ -235,6 +238,7 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) } // We fallthrough here from the "while (1)" + lflag = hflag = hhflag = altflag = 0; fmt++; }