9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

fmtprint.c (616B)


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