vsprintf.c revision 302408
138032Speter/* Simple implementation of vsprintf for systems without it.
238032Speter   Highly system-dependent, but should work on most "traditional"
338032Speter   implementations of stdio; newer ones should already have vsprintf.
438032Speter   Written by Per Bothner of Cygnus Support.
538032Speter   Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
638032Speter   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
738032Speter
838032SpeterThis file is part of the libiberty library.  This library is free
938032Spetersoftware; you can redistribute it and/or modify it under the
1038032Speterterms of the GNU General Public License as published by the
1138032SpeterFree Software Foundation; either version 2, or (at your option)
1238032Speterany later version.
1338032Speter
1438032SpeterThis library is distributed in the hope that it will be useful,
1538032Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of
1638032SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1742575SpeterGNU General Public License for more details.
1838032Speter
1942575SpeterYou should have received a copy of the GNU General Public License
2038032Speteralong with GNU CC; see the file COPYING.  If not, write to
2138032Speterthe Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
2238032Speter
2338032SpeterAs a special exception, if you link this library with files
2438032Spetercompiled with a GNU compiler to produce an executable, this does not cause
2538032Speterthe resulting executable to be covered by the GNU General Public License.
2638032SpeterThis exception does not however invalidate any other reasons why
2738032Speterthe executable file might be covered by the GNU General Public License. */
2838032Speter
2938032Speter#include <ansidecl.h>
3038032Speter#include <stdarg.h>
3138032Speter#include <stdio.h>
3238032Speter#undef vsprintf
3338032Speter
3438032Speter#if defined _IOSTRG && defined _IOWRT
3538032Speter
3638032Speterint
3738032Spetervsprintf (char *buf, const char *format, va_list ap)
3838032Speter{
3938032Speter  FILE b;
4038032Speter  int ret;
4138032Speter#ifdef VMS
4238032Speter  b->_flag = _IOWRT|_IOSTRG;
4338032Speter  b->_ptr = buf;
4438032Speter  b->_cnt = 12000;
4538032Speter#else
4638032Speter  b._flag = _IOWRT|_IOSTRG;
4738032Speter  b._ptr = buf;
4838032Speter  b._cnt = 12000;
4938032Speter#endif
5038032Speter  ret = _doprnt(format, ap, &b);
5138032Speter  putc('\0', &b);
5238032Speter  return ret;
5338032Speter
5438032Speter}
5538032Speter
5638032Speter#endif
5738032Speter