Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Use the correct SI symbols for binary scale factors consistently (MiB rather than MB).
Matthew Seaman committed 11 years ago
commit ba7d115aa30e1278b502c40262a698c9b64fba9c
parent 47f1875
5 files changed +26 -16
modified libpkg/pkg_jobs.c
@@ -2057,10 +2057,12 @@ pkg_jobs_fetch(struct pkg_jobs *j)

	if (dlsize > ((int64_t)fs.f_bsize * (int64_t)fs.f_bavail)) {
		int64_t fsize = (int64_t)fs.f_bsize * (int64_t)fs.f_bavail;
-
		char dlsz[8], fsz[8];
+
		char dlsz[9], fsz[9];

-
		humanize_number(dlsz, sizeof(dlsz), dlsize, "B", HN_AUTOSCALE, 0);
-
		humanize_number(fsz, sizeof(fsz), fsize, "B", HN_AUTOSCALE, 0);
+
		humanize_number(dlsz, sizeof(dlsz), dlsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);
+
		humanize_number(fsz, sizeof(fsz), fsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);
		pkg_emit_error("Not enough space in %s, needed %s available %s",
		    cachedir, dlsz, fsz);
		return (EPKG_FATAL);
modified src/clean.c
@@ -193,7 +193,7 @@ exec_clean(int argc, char **argv)
	int		 ch, cnt = 0;
	size_t		 total = 0, slen;
	ssize_t		 link_len;
-
	char		 size[7];
+
	char		 size[8];
	struct pkg_manifest_key *keys = NULL;

	struct option longopts[] = {
@@ -324,7 +324,8 @@ exec_clean(int argc, char **argv)
		goto cleanup;
	}

-
	humanize_number(size, sizeof(size), total, "B", HN_AUTOSCALE, 0);
+
	humanize_number(size, sizeof(size), total, "B",
+
	    HN_AUTOSCALE, HN_IEC_PREFIXES);

	printf("The cleanup will free %s\n", size);
	if (!dry_run) {
modified src/event.c
@@ -417,7 +417,7 @@ draw_progressbar(int64_t current, int64_t total)
	int percent;
	int64_t transferred;
	time_t elapsed = 0, now = 0;
-
	char buf[7];
+
	char buf[8];
	int64_t bytes_left;
	int cur_speed;
	int hours, minutes, seconds;
@@ -479,7 +479,7 @@ draw_progressbar(int64_t current, int64_t total)
				bytes_per_second = cur_speed;

			humanize_number(buf, sizeof(buf),
-
			    current,"B", HN_AUTOSCALE, 0);
+
			    current,"B", HN_AUTOSCALE, HN_IEC_PREFIXES);
			printf(" %*s", (int)sizeof(buf), buf);

			if (bytes_left > 0)
modified src/stats.c
@@ -58,7 +58,7 @@ exec_stats(int argc, char **argv)
	struct pkgdb	*db = NULL;
	int64_t		 flatsize = 0;
	unsigned int	 opt = 0;
-
	char		 size[7];
+
	char		 size[8];
	int		 ch;
	bool		 show_bytes = false;

@@ -115,7 +115,8 @@ exec_stats(int argc, char **argv)
		if (show_bytes)
			printf("\tDisk space occupied: %" PRId64 "\n\n", flatsize);
		else {
-
			humanize_number(size, sizeof(size), flatsize, "B", HN_AUTOSCALE, 0);
+
			humanize_number(size, sizeof(size), flatsize, "B",
+
			    HN_AUTOSCALE, HN_IEC_PREFIXES);
			printf("\tDisk space occupied: %s\n\n", size);
		}
	}
@@ -131,7 +132,8 @@ exec_stats(int argc, char **argv)
		if (show_bytes)
			printf("\tTotal size of packages: %" PRId64 "\n", flatsize);
		else {
-
			humanize_number(size, sizeof(size), flatsize, "B", HN_AUTOSCALE, 0);
+
			humanize_number(size, sizeof(size), flatsize, "B",
+
			    HN_AUTOSCALE, HN_IEC_PREFIXES);
			printf("\tTotal size of packages: %s\n", size);
		}
	}
modified src/utils.c
@@ -731,7 +731,7 @@ display_summary_item (struct pkg_solved_display_item *it, int64_t total_size,
{
	const char *why;
	int64_t pkgsize;
-
	char size[7], tlsize[7];
+
	char size[8], tlsize[8];

	pkg_get(it->new, PKG_PKGSIZE, &pkgsize);

@@ -790,8 +790,10 @@ display_summary_item (struct pkg_solved_display_item *it, int64_t total_size,
		printf("\n");
		break;
	case PKG_DISPLAY_FETCH:
-
		humanize_number(size, sizeof(size), pkgsize, "B", HN_AUTOSCALE, 0);
-
		humanize_number(tlsize, sizeof(size), dlsize, "B", HN_AUTOSCALE, 0);
+
		humanize_number(size, sizeof(size), pkgsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);
+
		humanize_number(tlsize, sizeof(size), dlsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);

		pkg_printf("\t%n-%v ", it->new, it->new);
		printf("(%.2f%% of %s: %s)\n", ((double)100 * pkgsize) / (double)dlsize,
@@ -862,15 +864,18 @@ print_jobs_summary(struct pkg_jobs *jobs, const char *msg, ...)
		puts("");

	if (oldsize > newsize) {
-
		humanize_number(size, sizeof(size), oldsize - newsize, "B", HN_AUTOSCALE, 0);
+
		humanize_number(size, sizeof(size), oldsize - newsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);
		printf("The operation will free %s.\n", size);
	} else if (newsize > oldsize) {
-
		humanize_number(size, sizeof(size), newsize - oldsize, "B", HN_AUTOSCALE, 0);
+
		humanize_number(size, sizeof(size), newsize - oldsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);
		printf("The process will require %s more space.\n", size);
	}

	if (dlsize > 0) {
-
		humanize_number(size, sizeof(size), dlsize, "B", HN_AUTOSCALE, 0);
+
		humanize_number(size, sizeof(size), dlsize, "B",
+
		    HN_AUTOSCALE, HN_IEC_PREFIXES);
		printf("%s to be downloaded.\n", size);
	}