mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
* stdio-common/printf_fp.c (___printf_fp): Cleanups and minor
optimization.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* Floating point output for `printf'.
|
||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2003, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library.
|
||||
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
||||
|
||||
@@ -811,12 +811,14 @@ ___printf_fp (FILE *fp,
|
||||
int chars_needed;
|
||||
int expscale;
|
||||
int intdig_max, intdig_no = 0;
|
||||
int fracdig_min, fracdig_max, fracdig_no = 0;
|
||||
int fracdig_min;
|
||||
int fracdig_max;
|
||||
int dig_max;
|
||||
int significant;
|
||||
int ngroups = 0;
|
||||
char spec = _tolower (info->spec);
|
||||
|
||||
if (_tolower (info->spec) == 'e')
|
||||
if (spec == 'e')
|
||||
{
|
||||
type = info->spec;
|
||||
intdig_max = 1;
|
||||
@@ -826,7 +828,7 @@ ___printf_fp (FILE *fp,
|
||||
dig_max = INT_MAX; /* Unlimited. */
|
||||
significant = 1; /* Does not matter here. */
|
||||
}
|
||||
else if (_tolower (info->spec) == 'f')
|
||||
else if (spec == 'f')
|
||||
{
|
||||
type = 'f';
|
||||
fracdig_min = fracdig_max = info->prec < 0 ? 6 : info->prec;
|
||||
@@ -887,7 +889,7 @@ ___printf_fp (FILE *fp,
|
||||
other output. If the amount of memory we have to allocate is too
|
||||
large use `malloc' instead of `alloca'. */
|
||||
buffer_malloced = ! __libc_use_alloca (chars_needed * 2 * sizeof (wchar_t));
|
||||
if (buffer_malloced)
|
||||
if (__builtin_expect (buffer_malloced, 0))
|
||||
{
|
||||
wbuffer = (wchar_t *) malloc ((2 + chars_needed) * sizeof (wchar_t));
|
||||
if (wbuffer == NULL)
|
||||
@@ -923,6 +925,7 @@ ___printf_fp (FILE *fp,
|
||||
}
|
||||
|
||||
/* Generate the needed number of fractional digits. */
|
||||
int fracdig_no = 0;
|
||||
while (fracdig_no < fracdig_min
|
||||
|| (fracdig_no < fracdig_max && (fracsize > 1 || frac[0] != 0)))
|
||||
{
|
||||
@@ -972,7 +975,7 @@ ___printf_fp (FILE *fp,
|
||||
/* Process fractional digits. Terminate if not rounded or
|
||||
radix character is reached. */
|
||||
while (*--wtp != decimalwc && *wtp == L'9')
|
||||
*wtp = '0';
|
||||
*wtp = L'0';
|
||||
if (*wtp != decimalwc)
|
||||
/* Round up. */
|
||||
(*wtp)++;
|
||||
|
Reference in New Issue
Block a user