fmtprint.c 465 B

1234567891011121314151617181920212223242526272829303132
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "fmtdef.h"
  4. /*
  5. * format a string into the output buffer
  6. * designed for formats which themselves call fmt,
  7. * but ignore any width flags
  8. */
  9. int
  10. fmtprint(Fmt *f, char *fmt, ...)
  11. {
  12. va_list va;
  13. int n;
  14. f->flags = 0;
  15. f->width = 0;
  16. f->prec = 0;
  17. va = f->args;
  18. va_start(f->args, fmt);
  19. n = dofmt(f, fmt);
  20. va_end(f->args);
  21. f->flags = 0;
  22. f->width = 0;
  23. f->prec = 0;
  24. f->args = va;
  25. if(n >= 0)
  26. return 0;
  27. return n;
  28. }