diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-01-19 21:43:15 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-01-19 21:43:15 +0000 |
commit | 0f0402929397bc020fa6e8f3fd9b78185cf76318 (patch) | |
tree | b51cdd3cd365f0b587e88246c8cf5ef6de459bf4 /apps/language.c | |
parent | 3c2fefdb99b24a000a5d896097cba479ad0e62a7 (diff) | |
download | rockbox-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 'apps/language.c')
-rw-r--r-- | apps/language.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/language.c b/apps/language.c index 2b9b6ff30b..847100e7da 100644 --- a/apps/language.c +++ b/apps/language.c | |||
@@ -25,9 +25,21 @@ extern int printf(const char *format, ...); | |||
25 | #include "language.h" | 25 | #include "language.h" |
26 | #include "lang.h" | 26 | #include "lang.h" |
27 | #include "debug.h" | 27 | #include "debug.h" |
28 | #include "string.h" | ||
28 | 29 | ||
29 | static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; | 30 | static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; |
30 | 31 | ||
32 | void lang_init(void) | ||
33 | { | ||
34 | int i; | ||
35 | unsigned char *ptr = (unsigned char *) language_builtin; | ||
36 | |||
37 | for (i = 0; i < LANG_LAST_INDEX_IN_ARRAY; i++) { | ||
38 | language_strings[i] = ptr; | ||
39 | ptr += strlen(ptr) + 1; /* advance pointer to next string */ | ||
40 | } | ||
41 | } | ||
42 | |||
31 | int lang_load(const char *filename) | 43 | int lang_load(const char *filename) |
32 | { | 44 | { |
33 | int filesize; | 45 | int filesize; |
@@ -39,6 +51,7 @@ int lang_load(const char *filename) | |||
39 | if(filesize != MAX_LANGUAGE_SIZE) { | 51 | if(filesize != MAX_LANGUAGE_SIZE) { |
40 | if((language_buffer[0] == LANGUAGE_COOKIE) && | 52 | if((language_buffer[0] == LANGUAGE_COOKIE) && |
41 | (language_buffer[1] == LANGUAGE_VERSION)) { | 53 | (language_buffer[1] == LANGUAGE_VERSION)) { |
54 | lang_init(); /* initialize with builtin */ | ||
42 | unsigned char *ptr=&language_buffer[2]; | 55 | unsigned char *ptr=&language_buffer[2]; |
43 | int id; | 56 | int id; |
44 | filesize-=2; | 57 | filesize-=2; |