portability touch-up (and ~15k size-savings)

Rich Felker dalias at aerifal.cx
Fri May 26 23:13:18 UTC 2006


On Fri, May 26, 2006 at 06:46:43PM -0400, Rob Landley wrote:
> On Thursday 25 May 2006 3:40 pm, Rich Felker wrote:
> > BTW about getopt_long... it might be worth dropping getopt entirely
> > and making a lightweight libbb function for handling options (both
> > short and long).
> 
> A fresh implementation of bb_getopt_ulflags() that doesn't use getopt at all 
> would be nice.  I'd be especially like it if _this_ one can handle
> tar xfjCv tarball.tbz dirname . without think that the tarball name I want is 
> "jCv" and that I want to put "tarball.tbz", "dirname", and "." in it...

Umm, I think the 'correct' unix semantics are that jCv is the filename
in this case, but I'm not sure... Nasty eh? :)

> Of course it depends on whether or not it actually saves size...

As long as it's written efficiently and _all_ references to getopt()
are removed it should definitely reduce size. With glibc (and uClibc)
the savings should be fairly significant. Built against my version
(which doesn't support the argv permutation thing) the savings will
probably be smaller but still nontrivial.

> > The bloated GNU permutation thing is only needed if 
> > the calling app wants to use the standard getopt loop idiom for
> > command line parsing; without that requirement the code could probably
> > be much smaller and still duplicate the commandline semantics.
> 
> And not screw up the command line.  See watch.c line 40, for example...

Yep I saw.

Rich




More information about the busybox mailing list