xref: /netbsd-src/external/gpl3/gdb/dist/libiberty/vsprintf.c (revision 7e120ff03ede3fe64e2c8620c01465d528502ddb)
198b9484cSchristos /* Simple implementation of vsprintf for systems without it.
298b9484cSchristos    Highly system-dependent, but should work on most "traditional"
398b9484cSchristos    implementations of stdio; newer ones should already have vsprintf.
498b9484cSchristos    Written by Per Bothner of Cygnus Support.
598b9484cSchristos    Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
6*7e120ff0Schristos    Copyright (C) 1991-2024 Free Software Foundation, Inc.
798b9484cSchristos 
898b9484cSchristos This file is part of the libiberty library.  This library is free
998b9484cSchristos software; you can redistribute it and/or modify it under the
1098b9484cSchristos terms of the GNU General Public License as published by the
1198b9484cSchristos Free Software Foundation; either version 2, or (at your option)
1298b9484cSchristos any later version.
1398b9484cSchristos 
1498b9484cSchristos This library is distributed in the hope that it will be useful,
1598b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1698b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1798b9484cSchristos GNU General Public License for more details.
1898b9484cSchristos 
1998b9484cSchristos You should have received a copy of the GNU General Public License
2098b9484cSchristos along with GNU CC; see the file COPYING.  If not, write to
2198b9484cSchristos the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
2298b9484cSchristos 
2398b9484cSchristos As a special exception, if you link this library with files
2498b9484cSchristos compiled with a GNU compiler to produce an executable, this does not cause
2598b9484cSchristos the resulting executable to be covered by the GNU General Public License.
2698b9484cSchristos This exception does not however invalidate any other reasons why
2798b9484cSchristos the executable file might be covered by the GNU General Public License. */
2898b9484cSchristos 
2998b9484cSchristos #include <ansidecl.h>
3098b9484cSchristos #include <stdarg.h>
3198b9484cSchristos #include <stdio.h>
3298b9484cSchristos #undef vsprintf
3398b9484cSchristos 
3498b9484cSchristos #if defined _IOSTRG && defined _IOWRT
3598b9484cSchristos 
3698b9484cSchristos int
3798b9484cSchristos vsprintf (char *buf, const char *format, va_list ap)
3898b9484cSchristos {
3998b9484cSchristos   FILE b;
4098b9484cSchristos   int ret;
4198b9484cSchristos #ifdef VMS
4298b9484cSchristos   b->_flag = _IOWRT|_IOSTRG;
4398b9484cSchristos   b->_ptr = buf;
4498b9484cSchristos   b->_cnt = 12000;
4598b9484cSchristos #else
4698b9484cSchristos   b._flag = _IOWRT|_IOSTRG;
4798b9484cSchristos   b._ptr = buf;
4898b9484cSchristos   b._cnt = 12000;
4998b9484cSchristos #endif
5098b9484cSchristos   ret = _doprnt(format, ap, &b);
5198b9484cSchristos   putc('\0', &b);
5298b9484cSchristos   return ret;
5398b9484cSchristos 
5498b9484cSchristos }
5598b9484cSchristos 
5698b9484cSchristos #endif
57