1169695Skan/* Simple implementation of vsprintf for systems without it.
2169695Skan   Highly system-dependent, but should work on most "traditional"
3169695Skan   implementations of stdio; newer ones should already have vsprintf.
4169695Skan   Written by Per Bothner of Cygnus Support.
5169695Skan   Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
6169695Skan   Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
7169695Skan
8169695SkanThis file is part of the libiberty library.  This library is free
9169695Skansoftware; you can redistribute it and/or modify it under the
10169695Skanterms of the GNU General Public License as published by the
11169695SkanFree Software Foundation; either version 2, or (at your option)
12169695Skanany later version.
13169695Skan
14169695SkanThis library is distributed in the hope that it will be useful,
15169695Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
16169695SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17169695SkanGNU General Public License for more details.
18169695Skan
19169695SkanYou should have received a copy of the GNU General Public License
20169695Skanalong with GNU CC; see the file COPYING.  If not, write to
21169695Skanthe Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22169695Skan
23169695SkanAs a special exception, if you link this library with files
24169695Skancompiled with a GNU compiler to produce an executable, this does not cause
25169695Skanthe resulting executable to be covered by the GNU General Public License.
26169695SkanThis exception does not however invalidate any other reasons why
27169695Skanthe executable file might be covered by the GNU General Public License. */
28169695Skan
29169695Skan#include <ansidecl.h>
30169695Skan#include <stdarg.h>
31169695Skan#include <stdio.h>
32169695Skan#undef vsprintf
33169695Skan
34169695Skan#if defined _IOSTRG && defined _IOWRT
35169695Skan
36169695Skanint
37169695Skanvsprintf (char *buf, const char *format, va_list ap)
38169695Skan{
39169695Skan  FILE b;
40169695Skan  int ret;
41169695Skan#ifdef VMS
42169695Skan  b->_flag = _IOWRT|_IOSTRG;
43169695Skan  b->_ptr = buf;
44169695Skan  b->_cnt = 12000;
45169695Skan#else
46169695Skan  b._flag = _IOWRT|_IOSTRG;
47169695Skan  b._ptr = buf;
48169695Skan  b._cnt = 12000;
49169695Skan#endif
50169695Skan  ret = _doprnt(format, ap, &b);
51169695Skan  putc('\0', &b);
52169695Skan  return ret;
53169695Skan
54169695Skan}
55169695Skan
56169695Skan#endif
57