aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-10-24 01:15:37 +0000
committerRoland McGrath <roland@gnu.org>2002-10-24 01:15:37 +0000
commit90d598708199f0506e390bb9866e4bdb592f858a (patch)
tree21303c2f0cbbd225561f60fd5e295f9fd5d98049 /sysdeps/generic
parent240e87c2300c25b1cc8a78cccc2293874d89c67e (diff)
downloadglibc-90d598708199f0506e390bb9866e4bdb592f858a.tar
glibc-90d598708199f0506e390bb9866e4bdb592f858a.tar.gz
glibc-90d598708199f0506e390bb9866e4bdb592f858a.tar.bz2
glibc-90d598708199f0506e390bb9866e4bdb592f858a.zip
* stdio-common/tst-fphex.c: New file.
* stdio-common/Makefile (tests): Add tst-fphex. * sysdeps/generic/printf_fphex.c (__printf_fphex): Fix initialization of WNUMEND. Fix counting of decimal point in WIDTH. Print '0' pad chars always before the value digits. Reported by James Antill <james.antill@redhat.com>.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/printf_fphex.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/sysdeps/generic/printf_fphex.c b/sysdeps/generic/printf_fphex.c
index 7dfb116aee..5b18c5ebb0 100644
--- a/sysdeps/generic/printf_fphex.c
+++ b/sysdeps/generic/printf_fphex.c
@@ -338,8 +338,8 @@ __printf_fphex (FILE *fp,
/* Look for trailing zeroes. */
if (! zero_mantissa)
{
- wnumend = wnumbuf + sizeof wnumbuf;
- numend = numbuf + sizeof numbuf;
+ wnumend = &wnumbuf[sizeof wnumbuf / sizeof wnumbuf[0]];
+ numend = &numbuf[sizeof numbuf / sizeof numbuf[0]];
while (wnumend[-1] == L'0')
{
--wnumend;
@@ -433,17 +433,13 @@ __printf_fphex (FILE *fp,
+ ((expbuf + sizeof expbuf) - expstr));
/* Exponent. */
- /* Count the decimal point. */
+ /* Count the decimal point.
+ A special case when the mantissa or the precision is zero and the `#'
+ is not given. In this case we must not print the decimal point. */
if (precision > 0 || info->alt)
width -= wide ? 1 : strlen (decimal);
- /* A special case when the mantissa or the precision is zero and the `#'
- is not given. In this case we must not print the decimal point. */
- if (precision == 0 && !info->alt)
- ++width; /* This nihilates the +1 for the decimal-point
- character in the following equation. */
-
- if (!info->left && width > 0)
+ if (!info->left && info->pad != '0' && width > 0)
PADN (' ', width);
if (negative)
@@ -458,6 +454,10 @@ __printf_fphex (FILE *fp,
outchar (info->spec + ('x' - 'a'));
else
outchar (info->spec == 'A' ? 'X' : 'x');
+
+ if (!info->left && info->pad == '0' && width > 0)
+ PADN ('0', width);
+
outchar (leading);
if (precision > 0 || info->alt)
@@ -474,9 +474,6 @@ __printf_fphex (FILE *fp,
PADN ('0', tofill);
}
- if (info->left && info->pad == '0' && width > 0)
- PADN ('0', width);
-
if ('P' - 'A' == 'p' - 'a')
outchar (info->spec + ('p' - 'a'));
else