summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2014-04-05 09:43:46 -0400
committerJason Woodward2014-04-05 09:43:46 -0400
commit240c358b583b0dc75f1eab4f56e7cbd27583008a (patch)
tree9abc2d8c30a8bb394fdee4ec038a6eb8fbb4050f
parent50243c8f669140e2943c353e77cebe00a85f6f39 (diff)
downloadslapt-get-240c358b583b0dc75f1eab4f56e7cbd27583008a.tar.gz
round after unit conversion
-rw-r--r--src/package.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/package.c b/src/package.c
index 1f055ad..59e8942 100644
--- a/src/package.c
+++ b/src/package.c
@@ -599,9 +599,9 @@ slapt_pkg_list_t *slapt_get_installed_pkgs(void)
char *size_c = slapt_regex_extract_match(compressed_size_reg, pkg_data, 1);
char *unit = slapt_regex_extract_match(compressed_size_reg, pkg_data, 2);
double c = strtof(size_c, (char **)NULL);
- tmp_pkg->size_c = round(c);
if ( strcmp(unit, "M") == 0 )
- tmp_pkg->size_c *= 1024;
+ c *= 1024;
+ tmp_pkg->size_c = round(c);
free(size_c);
free(unit);
}
@@ -612,9 +612,9 @@ slapt_pkg_list_t *slapt_get_installed_pkgs(void)
char *size_u = slapt_regex_extract_match(uncompressed_size_reg, pkg_data, 1);
char *unit = slapt_regex_extract_match(uncompressed_size_reg, pkg_data, 2);
double u = strtof(size_u, (char **)NULL);
- tmp_pkg->size_u = round(u);
if ( strcmp(unit, "M") == 0 )
- tmp_pkg->size_u *= 1024;
+ u *= 1024;
+ tmp_pkg->size_u = round(u);
free(size_u);
free(unit);
}