summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2009-10-17 13:40:42 +0000
committerNils Wallménius <nils@rockbox.org>2009-10-17 13:40:42 +0000
commit79f19b939f63a1a965bcc9f90cf9b6c8822620cc (patch)
treef2b6cd378e30daa15ce03653ae1dd3ded0a6431f
parent0659890804d8443a75b4cc5b91c6aec45821effc (diff)
downloadrockbox-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
-rw-r--r--apps/debug_menu.c4
-rw-r--r--apps/menus/main_menu.c17
-rw-r--r--apps/misc.c17
-rw-r--r--apps/misc.h5
-rw-r--r--apps/recorder/recording.c7
5 files changed, 21 insertions, 29 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index e863911602..9886843723 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1728,8 +1728,8 @@ static int disk_callback(int btn, struct gui_synclist *lists)
char *title = lists->title;
static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
- static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
- static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
+ static const unsigned char * const kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
+ static const unsigned char * const nsec_units[] = { "ns", "µs", "ms" };
#if (CONFIG_STORAGE & STORAGE_MMC)
static const char * const mmc_spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2",
"3.1-3.31", "4.0" };
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index 4208df413b..505801d3cc 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -150,20 +150,6 @@ enum infoscreenorder
INFO_COUNT
};
-static const unsigned char *kbyte_units[] =
-{
- ID2P(LANG_KILOBYTE),
- ID2P(LANG_MEGABYTE),
- ID2P(LANG_GIGABYTE)
-};
-
-static const unsigned char *byte_units[] =
-{
- ID2P(LANG_BYTE),
- ID2P(LANG_KILOBYTE),
- ID2P(LANG_MEGABYTE)
-};
-
static const char* info_getname(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
@@ -315,8 +301,7 @@ static int info_speak_item(int selected_item, void * data)
break;
case INFO_DISK1: /* disk 1 */
#ifdef HAVE_MULTIVOLUME
- talk_id(LANG_DISK_NAME_INTERNAL, false);
- talk_id(LANG_DISK_FREE_INFO, true);
+ talk_ids(false, LANG_DISK_NAME_INTERNAL, LANG_DISK_FREE_INFO);
output_dyn_value(NULL, 0, info->free, kbyte_units, true);
talk_id(LANG_DISK_SIZE_INFO, true);
output_dyn_value(NULL, 0, info->size, kbyte_units, true);
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 @@
#endif
#endif
+/* units used with output_dyn_value */
+const unsigned char * const byte_units[] =
+{
+ ID2P(LANG_BYTE),
+ ID2P(LANG_KILOBYTE),
+ ID2P(LANG_MEGABYTE),
+ ID2P(LANG_GIGABYTE)
+};
+
+const unsigned char * const * const kbyte_units = &byte_units[1];
+
/* Format a large-range value for output, using the appropriate unit so that
* the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
* units) if possible, and 3 significant digits are shown. If a buffer is
* given, the result is snprintf()'d into that buffer, otherwise the result is
* voiced.*/
char *output_dyn_value(char *buf, int buf_size, int value,
- const unsigned char **units, bool bin_scale)
+ const unsigned char * const *units, bool bin_scale)
{
int scale = bin_scale ? 1024 : 1000;
int fraction = 0;
@@ -827,9 +838,9 @@ char* skip_whitespace(char* const str)
{
char *s = str;
- while (isspace(*s))
+ while (isspace(*s))
s++;
-
+
return s;
}
diff --git a/apps/misc.h b/apps/misc.h
index 7e71101ba1..35972301cc 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -26,13 +26,16 @@
#include "config.h"
#include "system.h"
+extern const unsigned char * const byte_units[];
+extern const unsigned char * const * const kbyte_units;
+
/* Format a large-range value for output, using the appropriate unit so that
* the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
* units) if possible, and 3 significant digits are shown. If a buffer is
* given, the result is snprintf()'d into that buffer, otherwise the result is
* voiced.*/
char *output_dyn_value(char *buf, int buf_size, int value,
- const unsigned char **units, bool bin_scale);
+ const unsigned char * const *units, bool bin_scale);
/* Format time into buf.
*
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index ffa4b2df7e..da97306cfe 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -1035,13 +1035,6 @@ bool recording_screen(bool no_source)
int prev_rec_source = global_settings.rec_source; /* detect source change */
#endif
- static const unsigned char *byte_units[] = {
- ID2P(LANG_BYTE),
- ID2P(LANG_KILOBYTE),
- ID2P(LANG_MEGABYTE),
- ID2P(LANG_GIGABYTE)
- };
-
struct audio_recording_options rec_options;
rec_status = RCSTAT_IN_RECSCREEN;