Skip to content

Commit

Permalink
add float check
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Tsai committed Oct 28, 2020
1 parent 5b38d2e commit 536bec0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include "config.h"
#include "progress.h"
#include "gettext.h"
Expand All @@ -43,9 +44,12 @@ extern void progress_init(struct progress_bar *prog, int start, unsigned long lo
prog->stop = stop;
prog->total = total;

if ((stop - stop) == 0) {
prog->unit = 100.0 / (stop - start);
prog->total_unit = 100.0 / (total - start);
prog->unit = 100.0 / (stop - start);
prog->total_unit = 100.0 / (total - start);

if (!isnormal(prog->unit) || !isnormal(prog->total_unit)){
prog->unit = 0;
prog->total_unit = 0;
}

prog->initial_time = time(0);
Expand Down

0 comments on commit 536bec0

Please sign in to comment.