summaryrefslogtreecommitdiff
path: root/tools/genlang
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-01-19 21:43:15 +0000
committerJens Arnold <amiconn@rockbox.org>2005-01-19 21:43:15 +0000
commit0f0402929397bc020fa6e8f3fd9b78185cf76318 (patch)
treeb51cdd3cd365f0b587e88246c8cf5ef6de459bf4 /tools/genlang
parent3c2fefdb99b24a000a5d896097cba479ad0e62a7 (diff)
downloadrockbox-0f0402929397bc020fa6e8f3fd9b78185cf76318.tar.gz
rockbox-0f0402929397bc020fa6e8f3fd9b78185cf76318.zip
New way of handling the builtin language strings. Now the string pointers are no longer stored as initialised data, but calculated by walking one long string containing all language strings separated by \0. While this doesn't need more RAM, it fixes the problem that loading incomplete .lng files after complete ones did not reset the missing strings to the default, and it also decreases the binary size by >1700 bytes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5608 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/genlang')
-rwxr-xr-xtools/genlang15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/genlang b/tools/genlang
index e13cd3faf9..2677735d2e 100755
--- a/tools/genlang
+++ b/tools/genlang
@@ -30,8 +30,11 @@ print HFILE <<MOO
30 */ 30 */
31#define str(x) language_strings[x] 31#define str(x) language_strings[x]
32 32
33/* this is the array with all the strings */ 33/* this is the array for holding the string pointers.
34 It will be initialized at runtime. */
34extern unsigned char *language_strings[]; 35extern unsigned char *language_strings[];
36/* this contains the concatenation of all strings, separated by \0 chars */
37extern const unsigned char language_builtin[];
35 38
36/* The enum below contains all available strings */ 39/* The enum below contains all available strings */
37enum { 40enum {
@@ -41,8 +44,11 @@ MOO
41print CFILE <<MOO 44print CFILE <<MOO
42/* This file was automaticly generated using genlang, the strings come 45/* This file was automaticly generated using genlang, the strings come
43 from "$input" */ 46 from "$input" */
47
48#include "$prefix.h"
44 49
45unsigned char *language_strings[]={ 50unsigned char *language_strings[LANG_LAST_INDEX_IN_ARRAY];
51const unsigned char language_builtin[] =
46MOO 52MOO
47 ; 53 ;
48 54
@@ -85,7 +91,8 @@ while(<LANG>) {
85 } 91 }
86 else { 92 else {
87 push @hfile, $set{'id'}; 93 push @hfile, $set{'id'};
88 print CFILE " $value,\n"; 94 $value =~ s/\"$/\\0\"/;
95 print CFILE " $value\n";
89 } 96 }
90 97
91 undef %set; 98 undef %set;
@@ -118,7 +125,7 @@ MOO
118 ; 125 ;
119 126
120print CFILE <<MOO 127print CFILE <<MOO
121}; 128;
122/* end of generated string list */ 129/* end of generated string list */
123MOO 130MOO
124 ; 131 ;