Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide
translations



Rockbox mail archive

Subject: Re: What function loads a .lang file?

Re: What function loads a .lang file?

From: TP Diffenbach <rockbox_at_diffenbach.org>
Date: Mon, 28 Apr 2003 20:41:42 -0400

Quoting Daniel Stenberg <daniel_at_haxx.se>:

> On Sun, 27 Apr 2003 for_spam_at_gmx.de wrote:
>
> (As a comment to TP Diffenbach, I don't understand why you would
> need to copy a lot of strings. Using the ID number is enough and
> then you can use str(id) at the places where you need the string
> instead.)


(As a parenthetical answer to Daniel Stenberg :), I probably wrote this when I thought str() was a function, not a macro. I wanted to store the pointers precisely because I did not want to to copy them redundantly.

What I still want to avoid is code that copies the pointers to lang strings into local arrays:

char* some_lang_strings[] = { str( FOO ), str( BAR ), str( baz ) } ;

I'd prefer to pass the IDs where possible.

I also want to be able to index into the language_strings array to get a char** to a contiguous group of language_string[] elements. In other words, if I knew that all the LANG_FILE_PREFIX_OFFSET_x strings were in order, one after the other, and that the first one was LANG_FILE_PREFIX_OFFSET_AT, I'd be able to do the following to write out my setting: get the address of the lang string pointer with the address-of operator, giving me a char** I could index into:

    fprintf( fd, "%s: %s\r\n", str( LANG_FILE_PREFIX_OFFSET ),
             ( &str( LANG_FILE_PREFIX_OFFSET_AT ) )[
                (int) global_settings.strip_mp3_filename_after ] ) ;

I think Linus is skeptical of this, or perhaps I failed to explain well what I wanted to do. Of course this fails badly if the lang strings aren't ordered in language_strings (or if I index past the array, of course!), but I thought the make file generates code that orders them according to the order in english.lang.

Of course, I may be accused of early optimization (again!), but I'm trying to reduce code space as much as I can, aso as to have more of the 200KB .ajz space.

End parenthetical answer.)

-- 
Archos FM needs a Rockbox!
Received on 2003-04-29

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy