From 0ec078f9d24937e9d7d372e6a79fd76f92d12ec0 Mon Sep 17 00:00:00 2001 From: nls Date: Sat, 17 Oct 2009 13:40:42 +0000 Subject: [PATCH] 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 --- apps/debug_menu.c | 4 ++-- apps/menus/main_menu.c | 17 +---------------- apps/misc.c | 17 ++++++++++++++--- apps/misc.h | 5 ++++- apps/recorder/recording.c | 7 ------- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index e86391160..988684372 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 4208df413..505801d3c 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 3134e0255..4400de1b9 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 7e71101ba..35972301c 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 ffa4b2df7..da97306cf 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; -- 2.11.4.GIT