1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 03:12:48 +02:00

(human_readable): Avoid warnings from gcc -Wshadow.

This commit is contained in:
Jim Meyering
2002-11-08 15:33:30 +00:00
parent 2c3bb203cd
commit 554ecec785

View File

@@ -207,16 +207,13 @@ human_readable (uintmax_t n, char *buf, int opts,
opts & (human_round_to_nearest | human_floor | human_ceiling); opts & (human_round_to_nearest | human_floor | human_ceiling);
unsigned int base = opts & human_base_1024 ? 1024 : 1000; unsigned int base = opts & human_base_1024 ? 1024 : 1000;
uintmax_t amt; uintmax_t amt;
uintmax_t multiplier;
uintmax_t divisor;
uintmax_t r2;
uintmax_t r10;
int tenths = 0; int tenths = 0;
int exponent = -1; int exponent = -1;
int exponent_max = sizeof power_letter - 1; int exponent_max = sizeof power_letter - 1;
char *p; char *p;
char *psuffix; char *psuffix;
char const *integerlim; char const *integerlim;
int use_fp;
/* 0 means adjusted N == AMT.TENTHS; /* 0 means adjusted N == AMT.TENTHS;
1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05; 1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05;
@@ -246,19 +243,29 @@ human_readable (uintmax_t n, char *buf, int opts,
/* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */ /* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */
if (to_block_size <= from_block_size if (to_block_size <= from_block_size)
? (from_block_size % to_block_size != 0 {
|| (multiplier = from_block_size / to_block_size, uintmax_t multiplier;
(amt = n * multiplier) / multiplier != n)) use_fp = (from_block_size % to_block_size != 0
: (from_block_size == 0 || (multiplier = from_block_size / to_block_size,
|| to_block_size % from_block_size != 0 (amt = n * multiplier) / multiplier != n));
|| (divisor = to_block_size / from_block_size, }
r10 = (n % divisor) * 10, else
r2 = (r10 % divisor) * 2, {
amt = n / divisor, use_fp = (from_block_size == 0
tenths = r10 / divisor, || to_block_size % from_block_size != 0);
rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2), if (! use_fp)
0))) {
uintmax_t divisor = to_block_size / from_block_size;
uintmax_t r10 = (n % divisor) * 10;
uintmax_t r2 = (r10 % divisor) * 2;
amt = n / divisor;
tenths = r10 / divisor;
rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2);
}
}
if (use_fp)
{ {
/* Either the result cannot be computed easily using uintmax_t, /* Either the result cannot be computed easily using uintmax_t,
or from_block_size is zero. Fall back on floating point. or from_block_size is zero. Fall back on floating point.
@@ -277,7 +284,6 @@ human_readable (uintmax_t n, char *buf, int opts,
} }
else else
{ {
size_t buflen;
long double e = 1; long double e = 1;
exponent = 0; exponent = 0;