ref: a911bb38dfeb9667c1a69afa86edcedb1d47b218
parent: c48e71febf29a4600bc77c3e49390961bb718123
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 12 20:11:35 EDT 2020
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.
--- a/src/libc/stdio/vfprintf.c
+++ b/src/libc/stdio/vfprintf.c
@@ -186,6 +186,16 @@
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)
{