2015-03-11 Bernd Edlinger <bernd.edlinger@hotmail.de>
[official-gcc.git] / libiberty / vsprintf.c
blob99e704493f5844647387070d61c95784b6045588
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.
8 This file is part of the libiberty library. This library is free
9 software; you can redistribute it and/or modify it under the
10 terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23 As a special exception, if you link this library with files
24 compiled with a GNU compiler to produce an executable, this does not cause
25 the resulting executable to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
29 #include <ansidecl.h>
30 #include <stdarg.h>
31 #include <stdio.h>
32 #undef vsprintf
34 #if defined _IOSTRG && defined _IOWRT
36 int
37 vsprintf (char *buf, const char *format, va_list ap)
39 FILE b;
40 int ret;
41 #ifdef VMS
42 b->_flag = _IOWRT|_IOSTRG;
43 b->_ptr = buf;
44 b->_cnt = 12000;
45 #else
46 b._flag = _IOWRT|_IOSTRG;
47 b._ptr = buf;
48 b._cnt = 12000;
49 #endif
50 ret = _doprnt(format, ap, &b);
51 putc('\0', &b);
52 return ret;
56 #endif