Skip to content
Snippets Groups Projects
Commit b7d59bee authored by Yorhel's avatar Yorhel
Browse files

Properly display MiB units instead of MB

Fixes bug #2831412 (debian #539553)
parent 26c77cfc
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment