Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / gnu / lib / libg++ / libg++ / form.cc
CommitLineData
15637ed4
RG
1/*
2Copyright (C) 1990 Free Software Foundation
3 written by Doug Lea (dl@rocky.oswego.edu)
4
5This file is part of GNU CC.
6
7GNU CC is distributed in the hope that it will be useful,
8but WITHOUT ANY WARRANTY. No author or distributor
9accepts responsibility to anyone for the consequences of using it
10or for whether it serves any particular purpose or works at all,
11unless he says so in writing. Refer to the GNU CC General Public
12License for full details.
13
14Everyone is granted permission to copy, modify and redistribute
15GNU CC, but only under the conditions described in the
16GNU CC General Public License. A copy of this license is
17supposed to have been given to you along with GNU CC so you
18can know your rights and responsibilities. It should be in a
19file named COPYING. Among other things, the copyright notice
20and this notice must be preserved on all copies.
21*/
22
23#ifdef __GNUG__
24#pragma implementation
25#endif
26#include <builtin.h>
27#include <stdio.h>
28#include <stdarg.h>
29#include <AllocRing.h>
30
31extern AllocRing _libgxx_fmtq;
32
33char* form(const char* fmt ...)
34{
35 va_list args;
36 va_start(args, fmt);
37 char* fmtbase = (char *) _libgxx_fmtq.alloc(BUFSIZ);
38#ifndef HAVE_VPRINTF
39 FILE b;
40#ifdef VMS
41 b->_flag = _IOWRT|_IOSTRG;
42 b->_ptr = fmtbase;
43 b->_cnt = BUFSIZ-1;
44#else
45 b._flag = _IOWRT|_IOSTRG;
46 b._ptr = fmtbase;
47 b._cnt = BUFSIZ-1;
48#endif
49 _doprnt(fmt, args, &b);
50 putc('\0', &b);
51#else
52 vsprintf(fmtbase, fmt, args);
53#endif
54 va_end(args);
55 return fmtbase;
56}