~ubuntu-branches/ubuntu/hardy/gnupg2/hardy-proposed

« back to all changes in this revision

Viewing changes to intl/vasnprintf.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2007-05-15 13:54:55 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070515135455-89qfyalmgjy6gcqw
Tags: 2.0.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Remove libpcsclite-dev, libopensc2-dev build dependencies (they are in
    universe).
  - Build-depend on libcurl3-gnutls-dev
  - g10/call-agent.c: set DBG_ASSUAN to 0 to suppress a debug message
  - Include /doc files as done with gnupg
  - debian/rules: add doc/com-certs.pem to the docs for gpgsm
  - debian/copyright: update download url
  - debian/README.Debian: remove note the gnupg2 isn't released yet.
  - debian/control: Change Maintainer/XSBC-Original-Maintainer field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# define _GNU_SOURCE    1
24
24
#endif
25
25
 
26
 
#ifdef HAVE_CONFIG_H
27
 
# include <config.h>
28
 
#endif
 
26
#include <config.h>
29
27
#ifndef IN_LIBINTL
30
28
# include <alloca.h>
31
29
#endif
41
39
#include <stdlib.h>     /* abort(), malloc(), realloc(), free() */
42
40
#include <string.h>     /* memcpy(), strlen() */
43
41
#include <errno.h>      /* errno */
44
 
#include <limits.h>     /* CHAR_BIT, INT_MAX */
 
42
#include <limits.h>     /* CHAR_BIT */
45
43
#include <float.h>      /* DBL_MAX_EXP, LDBL_MAX_EXP */
46
44
#if WIDE_CHAR_VERSION
47
45
# include "wprintf-parse.h"
52
50
/* Checked size_t computations.  */
53
51
#include "xsize.h"
54
52
 
55
 
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW.  */
56
 
#ifndef EOVERFLOW
57
 
# define EOVERFLOW E2BIG
58
 
#endif
59
 
 
60
53
#ifdef HAVE_WCHAR_T
61
54
# ifdef HAVE_WCSLEN
62
55
#  define local_wcslen wcslen
256
249
                  case TYPE_COUNT_LONGINT_POINTER:
257
250
                    *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
258
251
                    break;
259
 
#ifdef HAVE_LONG_LONG
 
252
#ifdef HAVE_LONG_LONG_INT
260
253
                  case TYPE_COUNT_LONGLONGINT_POINTER:
261
254
                    *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
262
255
                    break;
330
323
                    {
331
324
 
332
325
                    case 'd': case 'i': case 'u':
333
 
# ifdef HAVE_LONG_LONG
 
326
# ifdef HAVE_LONG_LONG_INT
334
327
                      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
335
328
                        tmp_length =
336
329
                          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
360
353
                      break;
361
354
 
362
355
                    case 'o':
363
 
# ifdef HAVE_LONG_LONG
 
356
# ifdef HAVE_LONG_LONG_INT
364
357
                      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
365
358
                        tmp_length =
366
359
                          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
388
381
                      break;
389
382
 
390
383
                    case 'x': case 'X':
391
 
# ifdef HAVE_LONG_LONG
 
384
# ifdef HAVE_LONG_LONG_INT
392
385
                      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
393
386
                        tmp_length =
394
387
                          (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
535
528
 
536
529
                switch (type)
537
530
                  {
538
 
#ifdef HAVE_LONG_LONG
 
531
#ifdef HAVE_LONG_LONG_INT
539
532
                  case TYPE_LONGLONGINT:
540
533
                  case TYPE_ULONGLONGINT:
541
534
                    *p++ = 'l';
689
682
                          SNPRINTF_BUF (arg);
690
683
                        }
691
684
                        break;
692
 
#ifdef HAVE_LONG_LONG
 
685
#ifdef HAVE_LONG_LONG_INT
693
686
                      case TYPE_LONGLONGINT:
694
687
                        {
695
688
                          long long int arg = a.arg[dp->arg_index].a.a_longlongint;
870
863
      free (buf_malloced);
871
864
    CLEANUP ();
872
865
    *lengthp = length;
873
 
    if (length > INT_MAX)
874
 
      goto length_overflow;
 
866
    /* Note that we can produce a big string of a length > INT_MAX.  POSIX
 
867
       says that snprintf() fails with errno = EOVERFLOW in this case, but
 
868
       that's only because snprintf() returns an 'int'.  This function does
 
869
       not have this limitation.  */
875
870
    return result;
876
871
 
877
 
  length_overflow:
878
 
    /* We could produce such a big string, but its length doesn't fit into
879
 
       an 'int'.  POSIX says that snprintf() fails with errno = EOVERFLOW in
880
 
       this case.  */
881
 
    if (result != resultbuf)
882
 
      free (result);
883
 
    errno = EOVERFLOW;
884
 
    return NULL;
885
 
 
886
872
  out_of_memory:
887
873
    if (!(result == resultbuf || result == NULL))
888
874
      free (result);