[BusyBox] [patch] My bid to maintain sort.c.
Rob Landley
rob at landley.net
Sat Nov 27 19:34:51 UTC 2004
I had a free four-day weekend. I had caffiene. I rewrote busybox to be susv3
compliant.
Attached are three files:
1) sort.c is my big rewrite of coreutils/sort.c. No, it's not a patch against
the previous one, it's not really derived from the previous one. (For fun I
did a diff: the biggest instance of common code is the GPL boiler plate. The
next biggest is three consecutive lines of #includes which are in
alphabetical order. The only actual common lines of code are blank lines,
closing curly brackets, and one instance of "do {". I can provide it as a
patch against the previous version, but it's just silly...)
2) tests.sh is the big set of tests it passed (producing the same output as
sort from gnu coreutils, running "./tests.sh sort" and "./test.sh ./sort" and
diffing the output. I need to come up with some more tests before I can
really call it susv3 compliant, but what you see is a pretty good start.
Among other things, I still need to test the dot offsets to keys (-k 2.4,2.7
and so on...))
3) sort.patch is a small patch to libbbb/get_line_from_file.c (and
corresponding new line in libbb.h) to add a "read until null byte" mode,
which the -z option wants.
I haven't hacked the makefile/config stuff yet, but here's the option #ifdefs
I put into sort.c.
#defining CONFIG_SORT_BIG
This adds the full SuSv3 feature set (and 3.1k to the busybox executable). If
you leave that undefined, it produces a version with just the -u -n and -r
defines like before <smug>which is actually smaller than the old version
was</smug>. (And no longer dependent on
libcoreutils/xgetoptfile_sort_uniq.c, which may be dead code now.)
I tested that those three options worked with the #ifdef off, but that was a
while ago. If I accidentally broke something, I'll fix it...
#define CONFIG_SORT_GNUEXT
This adds in some GNU extensions like -g and -M, which are fairly small by
themselves but pull in library files that may be unpleasant in a hand tuned
statically linked environment.
Rob
P.S. If I don't answer email about this immediately, it's because I didn't
actually get to bed last night and may in fact pass out soon...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sort.patch
Type: text/x-diff
Size: 1095 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20041127/c96ce29a/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sort.c
Type: text/x-csrc
Size: 9107 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20041127/c96ce29a/attachment.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tests.sh
Type: application/x-shellscript
Size: 3020 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20041127/c96ce29a/attachment-0001.bin
More information about the busybox
mailing list