index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2012-02-02 22:36:46 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-02-03 08:56:17 -0600 |
commit | e01fdc3dba36336bf4acbbf5ea1e3f7ac9c6fb6a (patch) | |
tree | ec848a24dad0b524e4759051d65743e233fdb38b /src | |
parent | e8db984ce5997ffabafab2584fa7f00789ff3afd (diff) |
-rw-r--r-- | src/pacman/util.c | 15 |
diff --git a/src/pacman/util.c b/src/pacman/util.c index 96284a33..14e6f6b7 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -36,7 +36,6 @@ #include <unistd.h> #include <limits.h> #include <wchar.h> -#include <math.h> /* pow */ #ifdef HAVE_TERMIOS_H #include <termios.h> /* tcflush */ #endif @@ -989,6 +988,17 @@ static char *pkg_get_location(alpm_pkg_t *pkg) } } +/* a pow() implementation that is specialized for an integer base and small, + * positive-only integer exponents. */ +static double simple_pow(int base, int exp) +{ + double result = 1.0; + for(; exp > 0; exp--) { + result *= base; + } + return result; +} + /** Converts sizes in bytes into human readable units. * * @param bytes the size in bytes @@ -1025,7 +1035,8 @@ double humanize_size(off_t bytes, const char target_unit, int precision, } /* fix FS#27924 so that it doesn't display negative zeroes */ - if(precision >= 0 && val < 0.0 && val > (-0.5 / pow(10, precision))) { + if(precision >= 0 && val < 0.0 && + val > (-0.5 / simple_pow(10, precision))) { val = 0.0; } |