aboutsummaryrefslogtreecommitdiffstats
path: root/intl/vasnprintf.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2007-05-07 19:49:12 +0000
committerWerner Koch <[email protected]>2007-05-07 19:49:12 +0000
commitd5052fd22864ebb879e3b417ecfefd88e6c1800a (patch)
tree82f547df2e3ac98021fd713f470cc00610482c8e /intl/vasnprintf.c
parentUpdated to automake 1.10. (diff)
downloadgnupg-d5052fd22864ebb879e3b417ecfefd88e6c1800a.tar.gz
gnupg-d5052fd22864ebb879e3b417ecfefd88e6c1800a.zip
Upgraded gettext.
Fixed accidental dependency on libgcrypt 1.3.0.
Diffstat (limited to '')
-rw-r--r--intl/vasnprintf.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/intl/vasnprintf.c b/intl/vasnprintf.c
index cef29a756..8b073103b 100644
--- a/intl/vasnprintf.c
+++ b/intl/vasnprintf.c
@@ -23,9 +23,7 @@
# define _GNU_SOURCE 1
#endif
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
#ifndef IN_LIBINTL
# include <alloca.h>
#endif
@@ -41,7 +39,7 @@
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
#include <string.h> /* memcpy(), strlen() */
#include <errno.h> /* errno */
-#include <limits.h> /* CHAR_BIT, INT_MAX */
+#include <limits.h> /* CHAR_BIT */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
@@ -52,11 +50,6 @@
/* Checked size_t computations. */
#include "xsize.h"
-/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
-#ifndef EOVERFLOW
-# define EOVERFLOW E2BIG
-#endif
-
#ifdef HAVE_WCHAR_T
# ifdef HAVE_WCSLEN
# define local_wcslen wcslen
@@ -256,7 +249,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
case TYPE_COUNT_LONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longint_pointer = length;
break;
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
case TYPE_COUNT_LONGLONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
break;
@@ -330,7 +323,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
{
case 'd': case 'i': case 'u':
-# ifdef HAVE_LONG_LONG
+# ifdef HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
@@ -360,7 +353,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 'o':
-# ifdef HAVE_LONG_LONG
+# ifdef HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
@@ -388,7 +381,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 'x': case 'X':
-# ifdef HAVE_LONG_LONG
+# ifdef HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
@@ -535,7 +528,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
switch (type)
{
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
case TYPE_ULONGLONGINT:
*p++ = 'l';
@@ -689,7 +682,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
SNPRINTF_BUF (arg);
}
break;
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
{
long long int arg = a.arg[dp->arg_index].a.a_longlongint;
@@ -870,19 +863,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
free (buf_malloced);
CLEANUP ();
*lengthp = length;
- if (length > INT_MAX)
- goto length_overflow;
+ /* Note that we can produce a big string of a length > INT_MAX. POSIX
+ says that snprintf() fails with errno = EOVERFLOW in this case, but
+ that's only because snprintf() returns an 'int'. This function does
+ not have this limitation. */
return result;
- length_overflow:
- /* We could produce such a big string, but its length doesn't fit into
- an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in
- this case. */
- if (result != resultbuf)
- free (result);
- errno = EOVERFLOW;
- return NULL;
-
out_of_memory:
if (!(result == resultbuf || result == NULL))
free (result);