diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-11-11 14:49:35 -0800 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-11-11 14:49:35 -0800 |
commit | c65794b50b1bc729e7a4e940b76a973afa3030b9 (patch) | |
tree | bc435fea0f3179ac9a4b8de9fdaf993dade9e4ff /sys/libfmt/vesprint.c | |
parent | cc7d219e080263da9813e570436bfd34ab8b1bff (diff) |
feat: libfmt prototype added from plan9
Diffstat (limited to 'sys/libfmt/vesprint.c')
-rw-r--r-- | sys/libfmt/vesprint.c | 26 |
1 files changed, 26 insertions, 0 deletions
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; +} |