summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-05-01 09:07:28 +0200
committerYorhel <git@yorhel.nl>2009-05-01 09:07:28 +0200
commit0fe0d11e3b5198fa45ff3a587e1d65f9742df591 (patch)
tree6fcf12b6779be125ef914dd05d7a847b463d9f56
parent95b314de73664ddd08558e0d3bb243df656b74a9 (diff)
Don't divide by zero when size of parent dir = 0
It's a floating point division, so won't really cause any real problems on most systems. Still, a percentage of 'nan' isn't really useful.
-rw-r--r--src/browser.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/browser.c b/src/browser.c
index b353646..7d2e226 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -185,7 +185,9 @@ void browse_draw_item(struct dir *n, int row, off_t max, int ispar) {
size = formatsize(flags & BF_AS ? n->asize : n->size);
/* create graph (if necessary) */
- pc = ((float)(flags & BF_AS ? n->asize : n->size) / (float)(flags & BF_AS ? n->parent->asize : n->parent->size)) * 100.0f;
+ if((pc = (float)(flags & BF_AS ? n->parent->asize : n->parent->size)) < 1)
+ pc = 1.0f;
+ pc = ((float)(flags & BF_AS ? n->asize : n->size) / pc) * 100.0f;
if(graph == 1 || graph == 3) {
o = (int)(10.0f*(float)(flags & BF_AS ? n->asize : n->size) / (float)max);
for(i=0; i<10; i++)