here is setterm and a gratituos question
Jason Schoon
floydpink at gmail.com
Mon Sep 5 00:12:46 UTC 2005
Rob's right, the best way to save space with string constants is a lookup
table.
It doesn't cost any extra CPU time to do it the way I generally use. You
just create an array of static const strings, and use a pointer to the
desired string in all necessary places.
It has the benefit of having one change propogate to many place, just like
using a #define, however, the compiler can point all instances at the same
spot in memory. Also, as pointed out, it makes internationalization trivial.
On 9/4/05, Lord Sidiuz <alastors at gmail.com> wrote:
>
> >With a lookup table, we organize the suckers and make sure there's one
> copy of
> >them ourselves. And since we have to move it out to a seperate file for
> >translation purposes anyway, a lookup table is easy to do. (If all
> elsefails
> >it can be built by a script...)
> >
> >Rob
>
> I don't know what is a lookup table, if this takes cpu time I wont
> like it, i prefer
> to have a few duplacated strings, but I now that busybox is developed
> with sized in mind, not optimizacion.
>
> ok sow now i send the patch setterm i hope it gets to be in bb
>
> and one thing, the way i handle the arguments it copied from what i
> see in lots of code in bb but i really would like to do that in other
> way, how do you do that,
> what i have in mind is something like:
>
> while ( (opt = my_get_opt( argc, argv )) != -1 ) {
>
> switch ( opt ){
>
> case 215: //this is total for 'f'+'o'+'r'+'e'+'g'+'r'+'o'+'u'+'n'+'d'
> i++ ;
> loco= i+j ;
> gnsdkgn;
> sfdhfht();
> etc;
>
> case 232: //this is total for 'b'+'a'+'c'+'k'+'g'+'r'+'o'+'u'+'n'+'d'
> i++ ;
> loco= i+j ;
> gnsdkgn;
> sfdhfht();
> etc;
> }
>
> }
>
> i don't like to compare two strings so this does the same job but no
> strings are declared for compare later and i think is more eficient.
>
> but this has some bad things, i think it is not portable, it depends
> on the machine using ascii and two strings can have the same total
>
> what's your opinion??
>
> PD: I don't really know how to use diff nor patch so the file migth be
> dangerous use with care jeje.
>
> --
> No corrijas al necio no sea cosa que te odie, corrije al sabio y te lo
> agradecera.
> Al que a buen árbol se arrima buena sombra lo cobija.
> Debes tener siempre fría la cabeza, caliente el corazón y larga la mano.
> Lo mejor que podemos hacer por otro no es sólo compartir con él
> nuestras riquezas, sino mostrarle las suyas.
>
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20050904/f6fa506a/attachment-0002.htm
More information about the busybox
mailing list