xref: /plan9/sys/src/cmd/unix/drawterm/libc/fmtprint.c (revision 2282df4ee19682a10ae95200202320ff2912f104)
1 #include <u.h>
2 #include <libc.h>
3 #include "fmtdef.h"
4 
5 /*
6  * format a string into the output buffer
7  * designed for formats which themselves call fmt,
8  * but ignore any width flags
9  */
10 int
fmtprint(Fmt * f,char * fmt,...)11 fmtprint(Fmt *f, char *fmt, ...)
12 {
13 	va_list va;
14 	int n;
15 
16 	f->flags = 0;
17 	f->width = 0;
18 	f->prec = 0;
19 	VA_COPY(va, f->args);
20 	VA_END(f->args);
21 	va_start(f->args, fmt);
22 	n = dofmt(f, fmt);
23 	va_end(f->args);
24 	f->flags = 0;
25 	f->width = 0;
26 	f->prec = 0;
27 	VA_COPY(f->args,va);
28 	VA_END(va);
29 	if(n >= 0)
30 		return 0;
31 	return n;
32 }
33 
34