sprint.c 444 B

123456789101112131415161718192021222324
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "fmtdef.h"
  4. int
  5. sprint(char *buf, char *fmt, ...)
  6. {
  7. int n;
  8. uint len;
  9. va_list args;
  10. len = 1<<30; /* big number, but sprint is deprecated anyway */
  11. /*
  12. * on PowerPC, the stack is near the top of memory, so
  13. * we must be sure not to overflow a 32-bit pointer.
  14. */
  15. if(buf+len < buf)
  16. len = -(uintptr)buf-1;
  17. va_start(args, fmt);
  18. n = vsnprint(buf, len, fmt, args);
  19. va_end(args);
  20. return n;
  21. }