~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/printf/doprnt.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
   CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
5
5
   FUTURE GNU MP RELEASES.
6
6
 
7
 
Copyright 2001, 2002 Free Software Foundation, Inc.
 
7
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
8
8
 
9
9
This file is part of the GNU MP Library.
10
10
 
20
20
 
21
21
You should have received a copy of the GNU Lesser General Public License
22
22
along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
23
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24
 
MA 02111-1307, USA. */
 
23
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
24
MA 02110-1301, USA. */
 
25
 
 
26
#define _GNU_SOURCE    /* for DECIMAL_POINT in glibc langinfo.h */
25
27
 
26
28
#include "config.h"
27
29
 
45
47
# endif
46
48
#endif
47
49
 
 
50
#if HAVE_LANGINFO_H
 
51
#include <langinfo.h>  /* for nl_langinfo */
 
52
#endif
 
53
 
 
54
#if HAVE_LOCALE_H
 
55
#include <locale.h>    /* for localeconv */
 
56
#endif
 
57
 
48
58
#if HAVE_SYS_TYPES_H
49
59
#include <sys/types.h> /* for quad_t */
50
60
#endif
84
94
   "Z" was a type marker for size_t in old glibc, but there seems no need to
85
95
   provide access to that now "z" is standard.
86
96
 
 
97
   In GMP 4.1.1 we documented "ll" and "L" as being equivalent, but in C99
 
98
   in fact "ll" is just for long long and "L" just for long double.
 
99
   Apparentely GLIBC allows "L" for long long though.  This doesn't affect
 
100
   us as such, since both are passed through to the C library.  To be
 
101
   consistent with what we said before, the two are treated equivalently
 
102
   here, and it's left to the C library to do what it thinks with them.
 
103
 
87
104
   Possibilities:
88
105
 
89
106
   "b" might be nice for binary output, and could even be supported for the
160
177
     use __gmp_allocate_func rather than TMP_ALLOC, to avoid overflowing the
161
178
     stack if a long output string is given.  */
162
179
  alloc_fmt_size = strlen (orig_fmt) + 1;
 
180
#if _LONG_LONG_LIMB
 
181
  /* for a long long limb we change %Mx to %llx, so could need an extra 1
 
182
     char for every 3 existing */
 
183
  alloc_fmt_size += alloc_fmt_size / 3;
 
184
#endif
163
185
  alloc_fmt = __GMP_ALLOCATE_FUNC_TYPE (alloc_fmt_size, char);
164
186
  fmt = alloc_fmt;
165
187
  strcpy (fmt, orig_fmt);
281
303
                gmp_str = mpz_get_str (NULL, param.base, z);
282
304
                goto gmp_integer;
283
305
              }
284
 
              break;
 
306
              /* break; */
285
307
            case 'q':
286
308
              /* quad_t is probably the same as long long, but let's treat
287
309
                 it separately just to be sure.  Also let's assume u_quad_t
346
368
            case 'F':
347
369
              FLUSH ();
348
370
              DOPRNT_ACCUMULATE (__gmp_doprnt_mpf (funs, data, &param,
 
371
                                                   GMP_DECIMAL_POINT,
349
372
                                                   va_arg (ap, mpf_srcptr)));
350
373
              va_copy (last_ap, ap);
351
374
              last_fmt = fmt;
405
428
            /* glibc strerror(errno), no argument */
406
429
            goto next;
407
430
            
 
431
          case 'M': /* mp_limb_t */
 
432
            /* mung format string to l or ll and let plain printf handle it */
 
433
#if _LONG_LONG_LIMB
 
434
            memmove (fmt+1, fmt, strlen (fmt)+1);
 
435
            fmt[-1] = 'l';
 
436
            fmt[0] = 'l';
 
437
            fmt++;
 
438
            type = 'L';
 
439
#else
 
440
            fmt[-1] = 'l';
 
441
            type = 'l';
 
442
#endif
 
443
            break;
 
444
 
408
445
          case 'n':
409
446
            {
410
447
              void  *p;