133965Sjdp/* Simple implementation of vsprintf for systems without it.
233965Sjdp   Highly system-dependent, but should work on most "traditional"
333965Sjdp   implementations of stdio; newer ones should already have vsprintf.
433965Sjdp   Written by Per Bothner of Cygnus Support.
533965Sjdp   Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
689857Sobrien   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
733965Sjdp
833965SjdpThis file is part of the libiberty library.  This library is free
933965Sjdpsoftware; you can redistribute it and/or modify it under the
1033965Sjdpterms of the GNU General Public License as published by the
1133965SjdpFree Software Foundation; either version 2, or (at your option)
1233965Sjdpany later version.
1333965Sjdp
1433965SjdpThis library is distributed in the hope that it will be useful,
1533965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of
1633965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1733965SjdpGNU General Public License for more details.
1833965Sjdp
1933965SjdpYou should have received a copy of the GNU General Public License
2033965Sjdpalong with GNU CC; see the file COPYING.  If not, write to
21218822Sdimthe Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
2233965Sjdp
2333965SjdpAs a special exception, if you link this library with files
2433965Sjdpcompiled with a GNU compiler to produce an executable, this does not cause
2533965Sjdpthe resulting executable to be covered by the GNU General Public License.
2633965SjdpThis exception does not however invalidate any other reasons why
2733965Sjdpthe executable file might be covered by the GNU General Public License. */
2833965Sjdp
29130561Sobrien#include <ansidecl.h>
30130561Sobrien#include <stdarg.h>
3133965Sjdp#include <stdio.h>
3233965Sjdp#undef vsprintf
3333965Sjdp
3489857Sobrien#if defined _IOSTRG && defined _IOWRT
3589857Sobrien
3633965Sjdpint
37218822Sdimvsprintf (char *buf, const char *format, va_list ap)
3833965Sjdp{
3933965Sjdp  FILE b;
4033965Sjdp  int ret;
4133965Sjdp#ifdef VMS
4233965Sjdp  b->_flag = _IOWRT|_IOSTRG;
4333965Sjdp  b->_ptr = buf;
4433965Sjdp  b->_cnt = 12000;
4533965Sjdp#else
4633965Sjdp  b._flag = _IOWRT|_IOSTRG;
4733965Sjdp  b._ptr = buf;
4833965Sjdp  b._cnt = 12000;
4933965Sjdp#endif
5033965Sjdp  ret = _doprnt(format, ap, &b);
5133965Sjdp  putc('\0', &b);
5233965Sjdp  return ret;
5333965Sjdp
5433965Sjdp}
5589857Sobrien
5689857Sobrien#endif
57