scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 4522220ff333d34cf402dd8bb449416c31716198
parent ec9e043ec5301497d5dfb5323316204ee6a73a4c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 13 May 2020 00:11:35 +0200

libc: Add local copy of strnlen to vfprintf

Vfprintf sued to use strnlen, which was removed of the repo because
it is not defined in C99. This solution  is a fast solution that
adds it as a static function in vfprintf.

Diffstat:
Msrc/libc/stdio/vfprintf.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/libc/stdio/vfprintf.c b/src/libc/stdio/vfprintf.c @@ -186,6 +186,16 @@ strout(char *s, size_t len, int width, int fill, FILE * restrict fp) return cnt; } +static size_t +strnlen(const char *s, size_t maxlen) +{ + size_t n; + + for (n = 0; n < maxlen && *s++; ++n) + ; + return n; +} + int vfprintf(FILE * restrict fp, const char * restrict fmt, va_list va) {