From c65794b50b1bc729e7a4e940b76a973afa3030b9 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 11 Nov 2021 14:49:35 -0800 Subject: feat: libfmt prototype added from plan9 --- sys/libfmt/vesprint.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sys/libfmt/vesprint.c (limited to 'sys/libfmt/vesprint.c') diff --git a/sys/libfmt/vesprint.c b/sys/libfmt/vesprint.c new file mode 100644 index 0000000..18f4dd2 --- /dev/null +++ b/sys/libfmt/vesprint.c @@ -0,0 +1,26 @@ +#include "internal.h" + +char* +fmt·vesprint(char *buf, char *end, char *fmt, va_list args) +{ + fmt·State io; + + if(end <= buf) + return nil; + + io.n = 0; + io.buffer.beg = io.buffer.cur = buf; + io.buffer.end = end-1; + io.flush = nil; + io.file = nil; + + va_copy(io.args, args); + + fmt·setlocale(&io, nil, nil, nil); + fmt·do(&io, fmt); + + va_end(io.args); + + *(io.buffer.cur) = 0; + return io.buffer.cur; +} -- cgit v1.2.1