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
This commit is contained in:
Nils Wallménius 2009-10-17 13:40:42 +00:00
parent 0659890804
commit 79f19b939f
5 changed files with 21 additions and 29 deletions

View file

@ -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" };

View file

@ -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);

View file

@ -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;
}

View file

@ -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.
*

View file

@ -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;