source: trunk/third/gmp/cxx/osdoprnti.cc @ 18191

Revision 18191, 1.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18190, which included commits to RCS files with non-trunk default branches.
RevLine 
[18190]1/* __gmp_doprnt_integer_ios -- integer formatted output to an ostream.
2
3   THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY.  THEY'RE ALMOST
4   CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
5   FUTURE GNU MP RELEASES.
6
7Copyright 2001 Free Software Foundation, Inc.
8
9This file is part of the GNU MP Library.
10
11The GNU MP Library is free software; you can redistribute it and/or modify
12it under the terms of the GNU Lesser General Public License as published by
13the Free Software Foundation; either version 2.1 of the License, or (at your
14option) any later version.
15
16The GNU MP Library is distributed in the hope that it will be useful, but
17WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
19License for more details.
20
21You should have received a copy of the GNU Lesser General Public License
22along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
23the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24MA 02111-1307, USA. */
25
26#include <iostream>
27#include <stdarg.h>    /* for va_list and hence doprnt_funs_t */
28#include <string.h>
29
30#include "gmp.h"
31#include "gmp-impl.h"
32
33#include <stdio.h>
34
35using namespace std;
36
37
38/* The gmp_asprintf support routines never give an error, so
39   __gmp_doprnt_integer shouldn't fail and it's return can just be checked
40   with an ASSERT.  */
41
42ostream&
43__gmp_doprnt_integer_ostream (ostream &o, struct doprnt_params_t *p,
44                              char *s)
45{
46  struct gmp_asprintf_t   d;
47  char  *result;
48  int   ret;
49
50  /* don't show leading zeros the way printf does */
51  p->prec = -1;
52 
53  GMP_ASPRINTF_T_INIT (d, &result);
54  ret = __gmp_doprnt_integer (&__gmp_asprintf_funs_noformat, &d, p, s);
55  ASSERT (ret != -1);
56  __gmp_asprintf_final (&d);
57  (*__gmp_free_func) (s, strlen(s)+1);
58
59  gmp_allocated_string alloc = result;
60  return o.write (result, strlen (result));
61}
Note: See TracBrowser for help on using the repository browser.