[BusyBox] Today's ash improvements

Manuel Novoa III mjn3 at busybox.net
Mon Aug 6 08:58:00 UTC 2001


On Sun, Aug 05, 2001 at 05:45:14PM -0700, Aaron Lehmann wrote:
> On Sun, Aug 05, 2001 at 08:36:24PM -0400, ?????? wrote:
> > > to (is_digit(c)||c=='!'||c=='#'||c=='$'||c=='*'||c=='-').
> > How about:
> > strchr("!@$%#$0123456789", c) or
> > is_digit(c)||strchr("!@$%#$", c)
> 
> Nice try, but the overhead of the function call adds about 32 bytes
> over my version.

How about this (admittedly cryptic) version:

#define is_special(c) \
    ( (((unsigned int)c) - 33 < 32) \
    	 && ((0xc1ff920dUL >> (((unsigned int)c) - 33)) & 1) )

Evaluates to 1 for c in "!#$*-0123456789?@", and 0 otherwise.

Assumes ASCII codes of course, but then so does the table implementation
your replacing in ash.c.

Manuel





More information about the busybox mailing list