diff options
author | Wilco Dijkstra <wdijkstr@arm.com> | 2015-09-18 21:19:48 +0100 |
---|---|---|
committer | Wilco Dijkstra <wdijkstr@arm.com> | 2015-09-18 21:19:48 +0100 |
commit | 89faa0340ad399ead8104f8fb6b7fed81f7d939c (patch) | |
tree | cc15f087d86807d128a1fa592d00890e6c0e5982 /stdio-common/printf_size.c | |
parent | 3cc652e951c71785032019fec82e3b8543d85305 (diff) | |
download | glibc-89faa0340ad399ead8104f8fb6b7fed81f7d939c.tar.gz glibc-89faa0340ad399ead8104f8fb6b7fed81f7d939c.tar.xz glibc-89faa0340ad399ead8104f8fb6b7fed81f7d939c.zip |
Cleanup a few cases where isinf is used to get the signbit to improve the readability and maintainability and allow inlining.
2015-09-18 Wilco Dijkstra <wdijkstr@arm.com> * math/w_tgamma.c (__ieee754_gamma_r): Use explicit sign check. * math/w_tgammaf.c (__ieee754_gammaf_r): Likewise. * math/w_tgammal.c (__ieee754_gammal_r): Likewise. * stdio-common/printf_fp.c (___printf_fp): Use signbit to get the sign. Use isinf macro to allow inlining. * stdio-common/printf_fphex.c (__printf_fphex): Likewise. * stdio-common/printf_size.c (__printf_size): Likewise.
Diffstat (limited to 'stdio-common/printf_size.c')
-rw-r--r-- | stdio-common/printf_size.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/stdio-common/printf_size.c b/stdio-common/printf_size.c index 7dcd58e0d8..216f1707d6 100644 --- a/stdio-common/printf_size.c +++ b/stdio-common/printf_size.c @@ -108,7 +108,7 @@ __printf_size (FILE *fp, const struct printf_info *info, fpnum; const void *ptr = &fpnum; - int fpnum_sign = 0; + int is_neg = 0; /* "NaN" or "Inf" for the special cases. */ const char *special = NULL; @@ -117,7 +117,6 @@ __printf_size (FILE *fp, const struct printf_info *info, struct printf_info fp_info; int done = 0; int wide = info->wide; - int res; /* Fetch the argument value. */ #ifndef __NO_LONG_DOUBLE_MATH @@ -130,11 +129,11 @@ __printf_size (FILE *fp, const struct printf_info *info, { special = "nan"; wspecial = L"nan"; - // fpnum_sign = 0; Already zero + // is_neg = 0; Already zero } - else if ((res = __isinfl (fpnum.ldbl))) + else if (isinf (fpnum.ldbl)) { - fpnum_sign = res; + is_neg = signbit (fpnum.ldbl); special = "inf"; wspecial = L"inf"; } @@ -155,11 +154,11 @@ __printf_size (FILE *fp, const struct printf_info *info, { special = "nan"; wspecial = L"nan"; - // fpnum_sign = 0; Already zero + // is_neg = 0; Already zero } - else if ((res = __isinf (fpnum.dbl.d))) + else if (isinf (fpnum.dbl.d)) { - fpnum_sign = res; + is_neg = signbit (fpnum.dbl.d); special = "inf"; wspecial = L"inf"; } @@ -175,14 +174,14 @@ __printf_size (FILE *fp, const struct printf_info *info, { int width = info->prec > info->width ? info->prec : info->width; - if (fpnum_sign < 0 || info->showsign || info->space) + if (is_neg || info->showsign || info->space) --width; width -= 3; if (!info->left && width > 0) PADN (' ', width); - if (fpnum_sign < 0) + if (is_neg) outchar ('-'); else if (info->showsign) outchar ('+'); |