1*0d601874SDavid du Colombier /* 2*0d601874SDavid du Colombier * The authors of this software are Rob Pike and Ken Thompson. 3*0d601874SDavid du Colombier * Copyright (c) 2002 by Lucent Technologies. 4*0d601874SDavid du Colombier * Permission to use, copy, modify, and distribute this software for any 5*0d601874SDavid du Colombier * purpose without fee is hereby granted, provided that this entire notice 6*0d601874SDavid du Colombier * is included in all copies of any software which is or includes a copy 7*0d601874SDavid du Colombier * or modification of this software and in all copies of the supporting 8*0d601874SDavid du Colombier * documentation for such software. 9*0d601874SDavid du Colombier * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10*0d601874SDavid du Colombier * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE 11*0d601874SDavid du Colombier * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12*0d601874SDavid du Colombier * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13*0d601874SDavid du Colombier */ 148ccd4a63SDavid du Colombier #include <u.h> 158ccd4a63SDavid du Colombier #include <libc.h> 168ccd4a63SDavid du Colombier #include "fmtdef.h" 178ccd4a63SDavid du Colombier 188ccd4a63SDavid du Colombier /* 198ccd4a63SDavid du Colombier * format a string into the output buffer 208ccd4a63SDavid du Colombier * designed for formats which themselves call fmt, 218ccd4a63SDavid du Colombier * but ignore any width flags 228ccd4a63SDavid du Colombier */ 238ccd4a63SDavid du Colombier int 248ccd4a63SDavid du Colombier fmtprint(Fmt *f, char *fmt, ...) 258ccd4a63SDavid du Colombier { 268ccd4a63SDavid du Colombier va_list va; 278ccd4a63SDavid du Colombier int n; 288ccd4a63SDavid du Colombier 298ccd4a63SDavid du Colombier f->flags = 0; 308ccd4a63SDavid du Colombier f->width = 0; 318ccd4a63SDavid du Colombier f->prec = 0; 32*0d601874SDavid du Colombier VA_COPY(va, f->args); 33*0d601874SDavid du Colombier VA_END(f->args); 348ccd4a63SDavid du Colombier va_start(f->args, fmt); 358ccd4a63SDavid du Colombier n = dofmt(f, fmt); 368ccd4a63SDavid du Colombier va_end(f->args); 378ccd4a63SDavid du Colombier f->flags = 0; 388ccd4a63SDavid du Colombier f->width = 0; 398ccd4a63SDavid du Colombier f->prec = 0; 40*0d601874SDavid du Colombier VA_COPY(f->args,va); 41*0d601874SDavid du Colombier VA_END(va); 428ccd4a63SDavid du Colombier if(n >= 0) 438ccd4a63SDavid du Colombier return 0; 448ccd4a63SDavid du Colombier return n; 458ccd4a63SDavid du Colombier } 468ccd4a63SDavid du Colombier 47