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