diff options
author | Nils Wallménius <nils@rockbox.org> | 2009-10-17 13:40:42 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2009-10-17 13:40:42 +0000 |
commit | 79f19b939f63a1a965bcc9f90cf9b6c8822620cc (patch) | |
tree | f2b6cd378e30daa15ce03653ae1dd3ded0a6431f /apps/misc.c | |
parent | 0659890804d8443a75b4cc5b91c6aec45821effc (diff) | |
download | rockbox-79f19b939f63a1a965bcc9f90cf9b6c8822620cc.tar.gz rockbox-79f19b939f63a1a965bcc9f90cf9b6c8822620cc.zip |
Const correctness for output_dyn_value and unify some identical constants
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23227 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 17 |
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 */ | ||
88 | const unsigned char * const byte_units[] = | ||
89 | { | ||
90 | ID2P(LANG_BYTE), | ||
91 | ID2P(LANG_KILOBYTE), | ||
92 | ID2P(LANG_MEGABYTE), | ||
93 | ID2P(LANG_GIGABYTE) | ||
94 | }; | ||
95 | |||
96 | const 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.*/ |
92 | char *output_dyn_value(char *buf, int buf_size, int value, | 103 | char *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 | ||