summaryrefslogtreecommitdiffstats
path: root/apps/language.c
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 /apps/language.c
parent3c2fefdb99b24a000a5d896097cba479ad0e62a7 (diff)
downloadrockbox-0f0402929397bc020fa6e8f3fd9b78185cf76318.tar.gz
rockbox-0f0402929397bc020fa6e8f3fd9b78185cf76318.tar.bz2
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.c13
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, ...);
#include "language.h"
#include "lang.h"
#include "debug.h"
+#include "string.h"
static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
+void lang_init(void)
+{
+ int i;
+ unsigned char *ptr = (unsigned char *) language_builtin;
+
+ for (i = 0; i < LANG_LAST_INDEX_IN_ARRAY; i++) {
+ language_strings[i] = ptr;
+ ptr += strlen(ptr) + 1; /* advance pointer to next string */
+ }
+}
+
int lang_load(const char *filename)
{
int filesize;
@@ -39,6 +51,7 @@ int lang_load(const char *filename)
if(filesize != MAX_LANGUAGE_SIZE) {
if((language_buffer[0] == LANGUAGE_COOKIE) &&
(language_buffer[1] == LANGUAGE_VERSION)) {
+ lang_init(); /* initialize with builtin */
unsigned char *ptr=&language_buffer[2];
int id;
filesize-=2;