Package: gtkdiskfree
Version: 1.9.3-4sarge1
I noticed there is a small glitch in the output of gtkdiskfree in
the size columns. When the display mode is in AUTO (HUMANREADABLE)
and one value is very close to a full Gigabyte, etc., the /intended/
behaviour is printing e.g. 1 G but in fact, gtkdiskfree prints
just 1 which is bad from a usability perspective because the user
might wonder 1 .. WHAT? - she is left totally unclear about the
size except for its numeric value.
The following is a patch that fixes the problem. At the end you will
find another patch that also cleans up the code such that similar
bugs will either not happen or happen under any circumstances.
*** gtkdiskfree-1.9.3.orig/src/diskfree.c 2002-12-10
00:32:49.0 +0100
--- gtkdiskfree-1.9.3/src/diskfree.c2006-07-22 21:04:50.0 +0200
***
*** 355,357
if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f, test);
else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
--- 355,357
if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f T, test);
else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
***
*** 363,365
if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f, test);
else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
--- 363,365
if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f G, test);
else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
***
*** 371,373
if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f, test);
else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
--- 371,373
if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f M, test);
else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
-- Next (alternative) patch
*** gtkdiskfree-1.9.3.orig/src/diskfree.c 2002-12-10
00:32:49.0 +0100
--- gtkdiskfree-1.9.3/src/diskfree.c2006-07-22 21:19:57.0 +0200
***
*** 313,314
--- 313,330
+
+ gchar *
+ list_filesystem_size_inner(gfloat test, gchar *suffix) {
+ gchar *size;
+
+ if (((gfloat) ceil((gdouble) test) - test) = 0.01)
+ size = g_strdup_printf(%.0f%s, test, suffix);
+ else if ((test - (gfloat) floor((gdouble) test)) = 0.01)
+ size = g_strdup_printf(%.2f%s, test, suffix);
+ else
+ size = g_strdup_printf(%.0f%s, test, suffix);
+
+ return size;
+ }
+
+
/* This function put values in the requested user format. According to
***
*** 333,340
test = value / KBLOCK;
! if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f, test);
! else if ((test - (gfloat) floor((gdouble) test)) = 0.01)
! size = g_strdup_printf(%.2f, test);
! else
! size = g_strdup_printf(%.0f, test);
break;
--- 349,351
test = value / KBLOCK;
! size = list_filesystem_size_inner(test, );
break;
***
*** 342,349
test = value / (KBLOCK * KBLOCK);
! if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f, test);
! else if ((test - (gfloat) floor((gdouble) test)) = 0.01)
! size = g_strdup_printf(%.2f, test);
! else
! size = g_strdup_printf(%.0f, test);
break;
--- 353,355
test = value / (KBLOCK * KBLOCK);
! size = list_filesystem_size_inner(test, );
break;
***
*** 354,377
test = value / (KBLOCK * KBLOCK * KBLOCK);
! if (((gfloat) ceil((gdouble) test) - test) = 0.01)
! size = g_strdup_printf(%.0f, test);
! else if ((test - (gfloat) floor((gdouble) test)) =
0.01)
! size = g_strdup_printf(%.2f T, test);
! else
! size = g_strdup_printf(%.0f T, test);
} else if (value KBLOCK * KBLOCK) {
test = value / (KBLOCK * KBLOCK);
! if (((gfloat) ceil((gdouble) test) -