summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-08-03 14:26:10 +0200
committerYorhel <git@yorhel.nl>2009-08-03 14:26:10 +0200
commitb7d59bee5b35bc291bdfac5487a8f38ddb995528 (patch)
treebf1da8178f43dba556a47667c99dc0f869a91bd4
parent26c77cfc148c057140807820276844fb6376cb42 (diff)
Properly display MiB units instead of MB
Fixes bug #2831412 (debian #539553)
-rw-r--r--ChangeLog1
-rw-r--r--src/browser.c24
-rw-r--r--src/util.c4
3 files changed, 15 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 71a2be3..42b3f14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ git - ?
- Fixed non-void return in void delete_process()
- Fixed several tiny memory leaks
- Return to previously opened directory on failed recalculation
+ - Properly display MiB units instead of MB (IEEE 1541 - bug #2831412)
1.5 - 2009-05-02
- Fixed incorrect apparent size on directory refresh
diff --git a/src/browser.c b/src/browser.c
index 3cb354a..e30e19b 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -161,10 +161,10 @@ void browse_draw_item(struct dir *n, int row, off_t max, int ispar) {
/* reference to parent dir has a different format */
if(ispar) {
mvhline(row, 0, ' ', wincols);
- o = graph == 0 ? 11 :
- graph == 1 ? 23 :
- graph == 2 ? 18 :
- 29 ;
+ o = graph == 0 ? 12 :
+ graph == 1 ? 24 :
+ graph == 2 ? 20 :
+ 31 ;
mvaddstr(row, o, "/..");
if(n->flags & FF_BSEL)
attroff(A_REVERSE);
@@ -200,20 +200,20 @@ void browse_draw_item(struct dir *n, int row, off_t max, int ispar) {
line = malloc(winrows+1);
switch(graph) {
case 0:
- sprintf(line, "%%c %%7s %%c%%-%ds", wincols-12);
- mvprintw(row, 0, line, ct, size, dt, cropstr(n->name, wincols-12));
+ sprintf(line, "%%c %%8s %%c%%-%ds", wincols-13);
+ mvprintw(row, 0, line, ct, size, dt, cropstr(n->name, wincols-13));
break;
case 1:
- sprintf(line, "%%c %%7s [%%10s] %%c%%-%ds", wincols-24);
- mvprintw(row, 0, line, ct, size, gr, dt, cropstr(n->name, wincols-24));
+ sprintf(line, "%%c %%8s [%%10s] %%c%%-%ds", wincols-25);
+ mvprintw(row, 0, line, ct, size, gr, dt, cropstr(n->name, wincols-25));
break;
case 2:
- sprintf(line, "%%c %%7s [%%5.1f%%%%] %%c%%-%ds", wincols-20);
- mvprintw(row, 0, line, ct, size, pc, dt, cropstr(n->name, wincols-19));
+ sprintf(line, "%%c %%8s [%%5.1f%%%%] %%c%%-%ds", wincols-21);
+ mvprintw(row, 0, line, ct, size, pc, dt, cropstr(n->name, wincols-21));
break;
case 3:
- sprintf(line, "%%c %%7s [%%5.1f%%%% %%10s] %%c%%-%ds", wincols-31);
- mvprintw(row, 0, line, ct, size, pc, gr, dt, cropstr(n->name, wincols-30));
+ sprintf(line, "%%c %%8s [%%5.1f%%%% %%10s] %%c%%-%ds", wincols-32);
+ mvprintw(row, 0, line, ct, size, pc, gr, dt, cropstr(n->name, wincols-32));
}
free(line);
diff --git a/src/util.c b/src/util.c
index 6c95ba0..bd4c637 100644
--- a/src/util.c
+++ b/src/util.c
@@ -33,7 +33,7 @@ int winrows, wincols;
int subwinr, subwinc;
char cropstrdat[4096];
-char formatsizedat[8];
+char formatsizedat[9]; /* "xxx.xMiB" */
char fullsizedat[20]; /* max: 999.999.999.999.999 */
char *getpathdat;
int getpathdatl = 0;
@@ -70,7 +70,7 @@ char *formatsize(const off_t from) {
else if(r < 1023e6f) { c = 'M'; r/=1048576.0f; }
else if(r < 1023e9f) { c = 'G'; r/=1073741824.0f; }
else { c = 'T'; r/=1099511627776.0f; }
- sprintf(formatsizedat, "%5.1f%cB", r, c);
+ sprintf(formatsizedat, "%5.1f%c%cB", r, c, c == ' ' ? ' ' : 'i');
return formatsizedat;
}