Make %t with real values use specified width if given.
The %t format did not use the width specified when displaying real values. It should now work the same as the integer version.
This commit is contained in:
parent
dd6a441312
commit
c71b9797ca
|
|
@ -300,6 +300,7 @@ static void format_time(unsigned mcd, int fsize,
|
||||||
static void format_time_real(unsigned mcd, int fsize,
|
static void format_time_real(unsigned mcd, int fsize,
|
||||||
double value, int time_units)
|
double value, int time_units)
|
||||||
{
|
{
|
||||||
|
int width;
|
||||||
|
|
||||||
/* The time_units is the units of the current scope, and also
|
/* The time_units is the units of the current scope, and also
|
||||||
of the value. If the scope units are different from the
|
of the value. If the scope units are different from the
|
||||||
|
|
@ -307,11 +308,15 @@ static void format_time_real(unsigned mcd, int fsize,
|
||||||
if (time_units != timeformat_info.units)
|
if (time_units != timeformat_info.units)
|
||||||
value *= pow(10.0, time_units - timeformat_info.units);
|
value *= pow(10.0, time_units - timeformat_info.units);
|
||||||
|
|
||||||
|
if (fsize == -1) {
|
||||||
|
width = timeformat_info.width - strlen(timeformat_info.suff);
|
||||||
|
} else {
|
||||||
|
width = fsize;
|
||||||
|
}
|
||||||
/* The timeformat_info.prec is the number of digits after the
|
/* The timeformat_info.prec is the number of digits after the
|
||||||
decimal point, no matter what the units. */
|
decimal point, no matter what the units. */
|
||||||
my_mcd_printf(mcd, "%*.*f%s", timeformat_info.width -
|
my_mcd_printf(mcd, "%*.*f%s", width, timeformat_info.prec, value,
|
||||||
strlen(timeformat_info.suff), timeformat_info.prec,
|
timeformat_info.suff);
|
||||||
value, timeformat_info.suff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue