Re: uniq with sort-like "--key" support (now with sort and join)
From:
Assaf Gordon
Subject:
Re: uniq with sort-like "--key" support (now with sort and join)
Date:
Wed, 13 Feb 2013 19:43:15 -0500
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4
More updates:
The attached patch converts 'sort' and 'join' to use the key comparison
functions in 'key-spec-parsing.c'.
Sort was straight-forward (as expected), mostly removing the duplicated code
and moving some more functions to key-spec-parsing.c.
Join required a bit of trickery (explained in the code), the main change is the
'keycmp()' function that now calls "keycompare()".
All tests pass for sort and join, but I suspect the join test-suite is not
exhaustive.
Join definitely needs more testing, but one immediate feature is join in
reverse order (which already works):
===
##
## Input files
##
$ cat j3.in
C 1
B 2
A 3
$ cat j4.in
C 9
A 8
##
## Existing join
##
$ join -a 1 -a 2 -o auto -e . -j1 j3.in j4.in
C 1 9
A . 8
B 2 .
join: j3.in:3: is not sorted: A 3
A 3 .
##
## new Join reverse
##
$ ./src/join --reverse -a 1 -a 2 -o auto -e . -j1 j3.in j4.in
C 1 9
B 2 .
A 3 8
===
Regards,
-gordon