summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 3134e02555..4400de1b92 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -84,13 +84,24 @@
84#endif 84#endif
85#endif 85#endif
86 86
87/* units used with output_dyn_value */
88const unsigned char * const byte_units[] =
89{
90 ID2P(LANG_BYTE),
91 ID2P(LANG_KILOBYTE),
92 ID2P(LANG_MEGABYTE),
93 ID2P(LANG_GIGABYTE)
94};
95
96const unsigned char * const * const kbyte_units = &byte_units[1];
97
87/* Format a large-range value for output, using the appropriate unit so that 98/* Format a large-range value for output, using the appropriate unit so that
88 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" 99 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
89 * units) if possible, and 3 significant digits are shown. If a buffer is 100 * units) if possible, and 3 significant digits are shown. If a buffer is
90 * given, the result is snprintf()'d into that buffer, otherwise the result is 101 * given, the result is snprintf()'d into that buffer, otherwise the result is
91 * voiced.*/ 102 * voiced.*/
92char *output_dyn_value(char *buf, int buf_size, int value, 103char *output_dyn_value(char *buf, int buf_size, int value,
93 const unsigned char **units, bool bin_scale) 104 const unsigned char * const *units, bool bin_scale)
94{ 105{
95 int scale = bin_scale ? 1024 : 1000; 106 int scale = bin_scale ? 1024 : 1000;
96 int fraction = 0; 107 int fraction = 0;
@@ -827,9 +838,9 @@ char* skip_whitespace(char* const str)
827{ 838{
828 char *s = str; 839 char *s = str;
829 840
830 while (isspace(*s)) 841 while (isspace(*s))
831 s++; 842 s++;
832 843
833 return s; 844 return s;
834} 845}
835 846