diff options
author | Bruno Haible <bruno@clisp.org> | 2007-02-25 21:16:09 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-23 12:14:41 +0200 |
commit | 3d2341d0d7ad9625f923da457aa9211b3058fb22 (patch) | |
tree | 85529c902b227293de3b7daae3261d2a13381b9e /gettext-runtime/libasprintf | |
parent | a0028d89d917d3faafed7dd20bbd72b077613809 (diff) | |
download | external_gettext-3d2341d0d7ad9625f923da457aa9211b3058fb22.zip external_gettext-3d2341d0d7ad9625f923da457aa9211b3058fb22.tar.gz external_gettext-3d2341d0d7ad9625f923da457aa9211b3058fb22.tar.bz2 |
Fix estimate of size needed for a 'a' or 'A' conversion.
Diffstat (limited to 'gettext-runtime/libasprintf')
-rw-r--r-- | gettext-runtime/libasprintf/ChangeLog | 5 | ||||
-rw-r--r-- | gettext-runtime/libasprintf/vasnprintf.c | 22 |
2 files changed, 26 insertions, 1 deletions
diff --git a/gettext-runtime/libasprintf/ChangeLog b/gettext-runtime/libasprintf/ChangeLog index 7b88676..6af8ceb 100644 --- a/gettext-runtime/libasprintf/ChangeLog +++ b/gettext-runtime/libasprintf/ChangeLog @@ -1,3 +1,8 @@ +2007-02-25 Bruno Haible <bruno@clisp.org> + + * vasnprintf.c (VASNPRINTF): Fix estimate of size needed for a 'a' or + 'A' conversion. + 2007-01-29 Bruno Haible <bruno@clisp.org> * printf-args.h: Use '#if HAVE_*' instead of '#ifdef HAVE_*'. diff --git a/gettext-runtime/libasprintf/vasnprintf.c b/gettext-runtime/libasprintf/vasnprintf.c index 48cac1b..fbc2d74 100644 --- a/gettext-runtime/libasprintf/vasnprintf.c +++ b/gettext-runtime/libasprintf/vasnprintf.c @@ -431,12 +431,32 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar break; case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': tmp_length = 12; /* sign, decimal point, exponent etc. */ tmp_length = xsum (tmp_length, precision); break; + case 'a': case 'A': +# if HAVE_LONG_DOUBLE + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else +# endif + tmp_length = + (unsigned int) (DBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); + break; + case 'c': # if HAVE_WINT_T && !WIDE_CHAR_VERSION if (type == TYPE_WIDE_CHAR) |