diff options
author | Nils Wallménius <nils@rockbox.org> | 2009-08-20 16:47:44 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2009-08-20 16:47:44 +0000 |
commit | 3200d04d75c5e7556ed8880b155533e881a4d1e1 (patch) | |
tree | 188e2c9525b25cb8922a14766e51ab02bad3f831 /apps/plugins/goban | |
parent | 0a1728444882cdbc6a0c815bd88464de25ad94e9 (diff) | |
download | rockbox-3200d04d75c5e7556ed8880b155533e881a4d1e1.tar.gz rockbox-3200d04d75c5e7556ed8880b155533e881a4d1e1.zip |
Make the formatter functions used by the settings return a pointer to avoid usless copying of lang strings, this brought with it a long chain of const correctness and a few random cleanups
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22440 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/goban')
-rw-r--r-- | apps/plugins/goban/goban.c | 20 | ||||
-rw-r--r-- | apps/plugins/goban/types.h | 2 | ||||
-rw-r--r-- | apps/plugins/goban/util.c | 2 |
3 files changed, 13 insertions, 11 deletions
diff --git a/apps/plugins/goban/goban.c b/apps/plugins/goban/goban.c index 65a03f6953..4e20e71a37 100644 --- a/apps/plugins/goban/goban.c +++ b/apps/plugins/goban/goban.c | |||
@@ -114,37 +114,39 @@ set_defaults (void) | |||
114 | autosave_time = 7; | 114 | autosave_time = 7; |
115 | } | 115 | } |
116 | 116 | ||
117 | static void | 117 | static const char* |
118 | komi_formatter (char *dest, size_t size, int menu_item, const char *unknown) | 118 | komi_formatter (char *dest, size_t size, int menu_item, const char *unknown) |
119 | { | 119 | { |
120 | (void) unknown; | 120 | (void) unknown; |
121 | snprint_fixed (dest, size, menu_item); | 121 | snprint_fixed (dest, size, menu_item); |
122 | return dest; | ||
122 | } | 123 | } |
123 | 124 | ||
124 | static void | 125 | static const char* |
125 | ruleset_formatter (char *dest, size_t size, int menu_item, const char *unknown) | 126 | ruleset_formatter (char *dest, size_t size, int menu_item, const char *unknown) |
126 | { | 127 | { |
127 | (void) unknown; | 128 | (void)dest, (void)size, (void)unknown; |
128 | rb->snprintf (dest, size, "%s", ruleset_names[menu_item]); | 129 | return ruleset_names[menu_item]; |
129 | } | 130 | } |
130 | 131 | ||
131 | static void | 132 | static const char* |
132 | autosave_formatter (char *dest, size_t size, int menu_item, const char * | 133 | autosave_formatter (char *dest, size_t size, int menu_item, const char * |
133 | unknown) | 134 | unknown) |
134 | { | 135 | { |
135 | (void) unknown; | 136 | (void) unknown; |
136 | if (menu_item == 0) | 137 | if (menu_item == 0) |
137 | { | 138 | { |
138 | rb->snprintf (dest, size, "Off"); | 139 | return "Off"; |
139 | } | 140 | } |
140 | else | 141 | else |
141 | { | 142 | { |
142 | rb->snprintf (dest, size, "%d minute%s", menu_item, | 143 | rb->snprintf (dest, size, "%d minute%s", menu_item, |
143 | menu_item == 1 ? "" : "s"); | 144 | menu_item == 1 ? "" : "s"); |
145 | return dest; | ||
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
147 | static void | 149 | static const char* |
148 | time_formatter (char *dest, size_t size, int menu_item, const char *unknown) | 150 | time_formatter (char *dest, size_t size, int menu_item, const char *unknown) |
149 | { | 151 | { |
150 | int time_values[4]; /* days hours minutes seconds */ | 152 | int time_values[4]; /* days hours minutes seconds */ |
@@ -183,8 +185,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown) | |||
183 | 185 | ||
184 | if (max_set == -1) | 186 | if (max_set == -1) |
185 | { | 187 | { |
186 | rb->snprintf (dest, size, "0"); | 188 | return "0"; |
187 | return; | ||
188 | } | 189 | } |
189 | 190 | ||
190 | for (i = min_set; i <= 3; ++i) | 191 | for (i = min_set; i <= 3; ++i) |
@@ -236,6 +237,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown) | |||
236 | dest += temp; | 237 | dest += temp; |
237 | size -= temp; | 238 | size -= temp; |
238 | } | 239 | } |
240 | return dest; | ||
239 | } | 241 | } |
240 | 242 | ||
241 | enum plugin_status | 243 | enum plugin_status |
diff --git a/apps/plugins/goban/types.h b/apps/plugins/goban/types.h index 216d41bc21..a7c2b9b0ae 100644 --- a/apps/plugins/goban/types.h +++ b/apps/plugins/goban/types.h | |||
@@ -218,7 +218,7 @@ struct prop_t | |||
218 | 218 | ||
219 | 219 | ||
220 | /* The names of the rulesets, ex. "AGA", "Japanese", etc. */ | 220 | /* The names of the rulesets, ex. "AGA", "Japanese", etc. */ |
221 | extern char *ruleset_names[]; | 221 | extern const char *ruleset_names[]; |
222 | 222 | ||
223 | /* IMPORTANT! keep in sync with ruleset_names!!! */ | 223 | /* IMPORTANT! keep in sync with ruleset_names!!! */ |
224 | enum ruleset_t | 224 | enum ruleset_t |
diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c index e9966311ef..0e83173f40 100644 --- a/apps/plugins/goban/util.c +++ b/apps/plugins/goban/util.c | |||
@@ -210,7 +210,7 @@ char *prop_names[] = { | |||
210 | 210 | ||
211 | /* These seems to be specified by the SGF specification. You can do free | 211 | /* These seems to be specified by the SGF specification. You can do free |
212 | form ones as well, but I haven't implemented that (and don't plan to) */ | 212 | form ones as well, but I haven't implemented that (and don't plan to) */ |
213 | char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" }; | 213 | const char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" }; |
214 | 214 | ||
215 | 215 | ||
216 | 216 | ||