source: trunk/gcc/libiberty/_doprnt.c@ 2810

Last change on this file since 2810 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.5 KB
Line 
1/* Provide a version of _doprnt in terms of fprintf.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3 Contributed by Kaveh Ghazi ([email protected]) 3/29/98
4
5This program is free software; you can redistribute it and/or modify it
6under the terms of the GNU General Public License as published by the
7Free Software Foundation; either version 2, or (at your option) any
8later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19#include "config.h"
20#include "ansidecl.h"
21#include "safe-ctype.h"
22
23#include <stdio.h>
24#ifdef ANSI_PROTOTYPES
25#include <stdarg.h>
26#else
27#include <varargs.h>
28#endif
29#ifdef HAVE_STRING_H
30#include <string.h>
31#endif
32#ifdef HAVE_STDLIB_H
33#include <stdlib.h>
34#endif
35
36#undef _doprnt
37
38#ifdef HAVE__DOPRNT
39#define TEST
40#endif
41
42#ifdef TEST /* Make sure to use the internal one. */
43#define _doprnt my_doprnt
44#endif
45
46#define COPY_VA_INT \
47 do { \
48 const int value = abs (va_arg (ap, int)); \
49 char buf[32]; \
50 ptr++; /* Go past the asterisk. */ \
51 *sptr = '\0'; /* NULL terminate sptr. */ \
52 sprintf(buf, "%d", value); \
53 strcat(sptr, buf); \