vsprintf.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Simple implementation of vsprintf for systems without it.
  2. Highly system-dependent, but should work on most "traditional"
  3. implementations of stdio; newer ones should already have vsprintf.
  4. Written by Per Bothner of Cygnus Support.
  5. Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
  6. Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
  7. This file is part of the libiberty library. This library is free
  8. software; you can redistribute it and/or modify it under the
  9. terms of the GNU General Public License as published by the
  10. Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING. If not, write to
  18. the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
  19. As a special exception, if you link this library with files
  20. compiled with a GNU compiler to produce an executable, this does not cause
  21. the resulting executable to be covered by the GNU General Public License.
  22. This exception does not however invalidate any other reasons why
  23. the executable file might be covered by the GNU General Public License. */
  24. #include <ansidecl.h>
  25. #include <stdarg.h>
  26. #include <stdio.h>
  27. #undef vsprintf
  28. #if defined _IOSTRG && defined _IOWRT
  29. int
  30. vsprintf (char *buf, const char *format, va_list ap)
  31. {
  32. FILE b;
  33. int ret;
  34. #ifdef VMS
  35. b->_flag = _IOWRT|_IOSTRG;
  36. b->_ptr = buf;
  37. b->_cnt = 12000;
  38. #else
  39. b._flag = _IOWRT|_IOSTRG;
  40. b._ptr = buf;
  41. b._cnt = 12000;
  42. #endif
  43. ret = _doprnt(format, ap, &b);
  44. putc('\0', &b);
  45. return ret;
  46. }
  47. #endif