[PATCH] ls: make -C exclusive with -l and -1 (bug 2959).

James Youngman jay at gnu.org
Sat Dec 18 15:45:29 UTC 2010


That patch increases the size of the text segment by 53 bytes (on my
system at least), I hope that's within the realms of the acceptable.
 We could recover some of this by removing the useless
LIST_MASK_TRIGGER feature, however, rather than do that immediately I
wanted to discuss the foo_TRIGGER usage in general in ls.c and options
for fully fixing bug 2959.

The foo_TRIGGER mechanism appears to be an attempt to deal with
mutually-exclusive options, and indeed does so in a way, but since it
considers the options in the order they appear in opt_flags rather
than the order they appear on the command line, it will resolve
options conflicts deterministically but in a way that doesn't depend
on the option order specified by the user.   The existing code in
getopt32 for resolving this requires conflicting options to have no
bits set in common and at the moment this isn't true for options like
-c and -u.   I don't think there are enough bits available in the
return value to change this either (it was possible for -C/-1 just by
re-ordering the enum values).

Since getopt() is linked in anyway, one solution is to call getopt()
directly rather than getopt32(), in order to expose the option
ordering to ls.c.   This seems like rather a
sledgehammer-to-crack-a-nut solution and will probably increase the
size of the busybox text.   I didn't want to just jump in and do that,
since I'm not (yet) very familiar with the busybox community's
preferences for code size vs. compliance trade-offs and other possible
reasons to prefer to hang on to getopt32() that I just don't know
about yet.

Thoughts and comments appreciated.

James.


More information about the busybox mailing list