summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-05 19:17:41 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-05 19:17:41 +0200
commit5a2e42e05c7ff8ea4c7b8fbf47315d6008435142 (patch)
tree9373ba9457c407db0387c8bcdf4e76f8e37cd509
parent18dd1c5ea218c1b86e305d3ee0052335b1e22fc8 (diff)
Correctly round human-readable file size
Closes #463
-rw-r--r--src/feh.h2
-rw-r--r--src/slideshow.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/feh.h b/src/feh.h
index 1d5e918..15da763 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -152,7 +152,7 @@ void feh_event_handle_stdin();
void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysym, unsigned int button);
fehkey *feh_str_to_kb(char * action);
void feh_action_run(feh_file * file, char *action, winwidget winwid);
-char *format_size(int size);
+char *format_size(double size);
char *feh_printf(char *str, feh_file * file, winwidget winwid);
void im_weprintf(winwidget w, char *fmt, ...);
void feh_draw_zoom(winwidget w);
diff --git a/src/slideshow.c b/src/slideshow.c
index 145ced1..ac8c545 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -445,7 +445,7 @@ void feh_action_run(feh_file * file, char *action, winwidget winwid)
return;
}
-char *format_size(int size)
+char *format_size(double size)
{
static char ret[5];
char units[] = {' ', 'k', 'M', 'G', 'T'};
@@ -454,7 +454,7 @@ char *format_size(int size)
size /= 1000;
postfix++;
}
- snprintf(ret, 5, "%3d%c", size, units[postfix]);
+ snprintf(ret, 5, "%3.0f%c", size, units[postfix]);
return ret;
}