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/write.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sys/libfmt/write.c (limited to 'sys/libfmt/write.c') diff --git a/sys/libfmt/write.c b/sys/libfmt/write.c new file mode 100644 index 0000000..9a77223 --- /dev/null +++ b/sys/libfmt/write.c @@ -0,0 +1,22 @@ +#include "internal.h" + +int +fmt·write(fmt·State *io, char *fmt, ...) +{ + int n; + va_list args; + + io->flag = io->width = io->prec = 0; + + va_copy(args, io->args); + va_end(io->args); + + va_start(io->args, fmt); + n = fmt·do(io, fmt); + va_end(io->args); + + io->flag = io->width = io->prec = 0; + if(n >= 0) + return 0; + return n; +} -- cgit v1.2.1