[BusyBox] calling getopt() centrally

Bob Tinsley bob at earthrise.demon.co.uk
Tue Dec 17 18:42:06 UTC 2002


[test-patch attached]

I hope the attached patch to current development CVS is
self-explanatory. The core idea is to optionally allow applets to make
use of a central getopt() function rather than including very similar
code for each one. This patch only updates a few fileutils applets (to
keep it simple at first) but already seems to shave a few bytes off the
default config.

Notes:

* If more applets are adapted to work this way, then much bigger savings
can be made as the one-off cost of the extra code has already been paid.

* Applets cannot be converted without changing semantics if the order of
flags is important. This is the case for surprisingly many of them as
'-f' and '-i' often over-ride each other, or you can select multiple
output formats. (In some cases, we might be able to take a view similar
to "if multiple output formats are chosen, then always go for this
one".)

* It's a looong time since I've looked at busybox (a couple of years or
more) and a few months since I've written any C so there may be bugs.
Sorry.

$ size */busybox
   text    data     bss     dec     hex filename
 166925    2572   27508  197005   3018d busybox.cvs/busybox
 166885    2572   27512  196969   30169 busybox.rjt1/busybox

As the patch will ultimately change half the source files, I'm looking
for any feedback and comments people might have before I put too much
work in ;)

Cheers,

Bob

--
rjt

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: busybox_patch1.txt
Url: http://lists.busybox.net/pipermail/busybox/attachments/20021217/8e55e499/attachment.txt 


More information about the busybox mailing list