From d03b57f459fb9ab9288991a70c4e7297a7c1d150 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 9 Jan 2011 20:36:42 -0600 Subject: Remove need for floating point division in backend All of these can be done with integer division; the only slightly interesting part is ensuring we round up like before with calling the ceil() function. We can also remove the math library from requirements; now that the only ceil() calls are gone, we don't need this anymore. Signed-off-by: Dan McGee --- lib/libalpm/add.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/libalpm/add.c') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 2f341eb0..d4c56def 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -477,8 +477,8 @@ static int extract_single_file(struct archive *archive, return(errors); } -static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, size_t pkg_count, - pmtrans_t *trans, pmdb_t *db) +static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, + size_t pkg_count, pmtrans_t *trans, pmdb_t *db) { int i, ret = 0, errors = 0; char scriptlet[PATH_MAX+1]; @@ -605,31 +605,31 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, size_t pkg_cou } for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) { - double percent; + int percent; if(newpkg->size != 0) { /* Using compressed size for calculations here, as newpkg->isize is not * exact when it comes to comparing to the ACTUAL uncompressed size * (missing metadata sizes) */ int64_t pos = archive_position_compressed(archive); - percent = (double)pos / (double)newpkg->size; + percent = (pos * 100) / newpkg->size; _alpm_log(PM_LOG_DEBUG, "decompression progress: " - "%f%% (%"PRId64" / %jd)\n", - percent*100.0, pos, (intmax_t)newpkg->size); - if(percent >= 1.0) { - percent = 1.0; + "%d%% (%"PRId64" / %jd)\n", + percent, pos, (intmax_t)newpkg->size); + if(percent >= 100) { + percent = 100; } } else { - percent = 0.0; + percent = 0; } if(is_upgrade) { PROGRESS(trans, PM_TRANS_PROGRESS_UPGRADE_START, - alpm_pkg_get_name(newpkg), (int)(percent * 100), pkg_count, + alpm_pkg_get_name(newpkg), percent, pkg_count, pkg_current); } else { PROGRESS(trans, PM_TRANS_PROGRESS_ADD_START, - alpm_pkg_get_name(newpkg), (int)(percent * 100), pkg_count, + alpm_pkg_get_name(newpkg), percent, pkg_count, pkg_current); } -- cgit v1.2.3-24-g4f1b