[BusyBox] Applet Hashing for Busybox

Tomi Ollila Tomi.Ollila at sonera.com
Wed Oct 25 11:26:23 UTC 2000


 Oct 25 11:39:57 +0100 2000 Gaute B Strokkenes <gs234 at cam.ac.uk> wrote:
> Tomi Ollila <Tomi.Ollila at sonera.com> writes:
> > As a quick resolution, your NUM_APPLETS is actually defined as count
> > of applets minus one ;)
> 
> No.  The last entry in applets[] is a dummy entry.  Hence the "- 1"
> term.  From applets.h :
> 
> /* The -1 arises because of the {0,NULL,0,NULL} entry above. */
> #define NUM_APPLETS (sizeof (applets) / sizeof (struct BB_applet) - 1)

Okei :D

> 

> > But it may happen that people are adding new applet in wrong place
> > but still binary search finds it. In this case people may end up
> > committing change without noticing that some other applet may not be
> > found.  I am in favour of generating the applet table during
> > compilation process.
> 
> The applet table is just an array that contains the applet name, a
> pointer to applet_main, the usage message and something that tells the
> installer where to put the symbolic link.  It's not so complicated as
> to warrant automatic generation, IMHO.  It's much easier just to have
> all debug builds check the order.

But, if one just adds a simple code without doing any debug builds... ?

> 
> > BTW, which tools are suitable for doing such a work, SH and c
> > programs certainly,
> 
> Using C would make bb very hard to cross-compile.

True!.. and this comes back to previous thing... if one cross-compiles,
forcing to do debug build for simple things may not be what sometimes
is desirable

> > but what about using awk, perl, python, etc for the job?
> 
> IMHO making the bb build depend on something as huge as perl or python
> isn't really worth it for something this simple.

That's why I asked... how about awk then? That comes with every unix
distribution, but how to make code that is compatible with all -- well,
the same problems is always with /bin/sh -programming (always remember
to test string equality/inequality with [ x$foo = x ] etc... otherwise
you may find problems when trying, for example, Solaris standard /bin/sh).


Anyway, any way it is done suits me fine ...

... hmm, the easiest way to do comparison for already coded and ordered
list might be to utilize following tricks:

$ sed -n 's/.*{ *\"\(.*\)\".*/\1/p' busybox.c >/tmp/bcomp.$$
$ sort /tmp/bcomp.$$ | diff /tmp/bcomp.$$ - >/dev/null 2>&1
$ [ $? != 0 ] && echo not in aplhabetical order
$ rm -f /tmp/bcomp.$$ -

> Gaute Strokkenes         http://www.srcf.ucam.org/~gs234/

Tomi





More information about the busybox mailing list