2008-06-15 Pavel Roskin <proski@gnu.org>
* commands/ls.c (grub_ls_list_files): Use integer calculations for human readable format, avoid floating point use. * kern/misc.c (grub_ftoa): Remove. (grub_vsprintf): Remove floating point support.
This commit is contained in:
parent
50465dd603
commit
95614c84f8
3 changed files with 14 additions and 34 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-06-15 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* commands/ls.c (grub_ls_list_files): Use integer calculations
|
||||||
|
for human readable format, avoid floating point use.
|
||||||
|
* kern/misc.c (grub_ftoa): Remove.
|
||||||
|
(grub_vsprintf): Remove floating point support.
|
||||||
|
|
||||||
2008-06-15 Robert Millan <rmh@aybabtu.com>
|
2008-06-15 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
* util/grub.d/10_linux.in: Use the underliing device for loop-AES
|
* util/grub.d/10_linux.in: Use the underliing device for loop-AES
|
||||||
|
|
|
@ -108,21 +108,25 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
||||||
grub_printf ("%-12llu", (unsigned long long) file->size);
|
grub_printf ("%-12llu", (unsigned long long) file->size);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float fsize = file->size;
|
grub_uint64_t fsize = file->size * 100ULL;
|
||||||
int fsz = file->size;
|
int fsz = file->size;
|
||||||
int units = 0;
|
int units = 0;
|
||||||
char buf[20];
|
char buf[20];
|
||||||
|
|
||||||
while (fsz / 1024)
|
while (fsz / 1024)
|
||||||
{
|
{
|
||||||
fsize /= 1024;
|
fsize = (fsize + 512) / 1024;
|
||||||
fsz /= 1024;
|
fsz /= 1024;
|
||||||
units++;
|
units++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (units)
|
if (units)
|
||||||
{
|
{
|
||||||
grub_sprintf (buf, "%0.2f%c", fsize, grub_human_sizes[units]);
|
grub_uint32_t whole, fraction;
|
||||||
|
|
||||||
|
whole = grub_divmod64 (fsize, 100, &fraction);
|
||||||
|
grub_sprintf (buf, "%u.%02u%c", whole, fraction,
|
||||||
|
grub_human_sizes[units]);
|
||||||
grub_printf ("%-12s", buf);
|
grub_printf ("%-12s", buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
31
kern/misc.c
31
kern/misc.c
|
@ -655,24 +655,6 @@ grub_lltoa (char *str, int c, unsigned long long n)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
grub_ftoa (char *str, double f, int round)
|
|
||||||
{
|
|
||||||
unsigned int intp;
|
|
||||||
unsigned int fractp;
|
|
||||||
unsigned int power = 1;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < round; i++)
|
|
||||||
power *= 10;
|
|
||||||
|
|
||||||
intp = f;
|
|
||||||
fractp = (f - (float) intp) * power;
|
|
||||||
|
|
||||||
grub_sprintf (str, "%d.%d", intp, fractp);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_vsprintf (char *str, const char *fmt, va_list args)
|
grub_vsprintf (char *str, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
@ -807,19 +789,6 @@ grub_vsprintf (char *str, const char *fmt, va_list args)
|
||||||
write_char (n & 0xff);
|
write_char (n & 0xff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
|
||||||
{
|
|
||||||
float f;
|
|
||||||
f = va_arg (args, double);
|
|
||||||
grub_ftoa (tmp, f, format2);
|
|
||||||
if (!rightfill && grub_strlen (tmp) < format1)
|
|
||||||
write_fill (zerofill, format1 - grub_strlen (tmp));
|
|
||||||
write_str (tmp);
|
|
||||||
if (rightfill && grub_strlen (tmp) < format1)
|
|
||||||
write_fill (zerofill, format1 - grub_strlen (tmp));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
{
|
{
|
||||||
grub_uint32_t code = va_arg (args, grub_uint32_t);
|
grub_uint32_t code = va_arg (args, grub_uint32_t);
|
||||||
|
|
Loading…
Reference in a new issue