Home | History | Annotate | Download | only in sort
History log of /src/usr.bin/sort/init.c
RevisionDateAuthorComments
 1.30  19-Sep-2021  andvar fix few more typos in comments, messages and documentation.
 1.29  18-Oct-2013  christos fix unused variable warnings
 1.28  18-Dec-2010  christos branches: 1.28.6; 1.28.12;
Add an 'l' style for sorting that sorts by the string length of the field.
 1.27  06-Jun-2010  wiz Fix typo in comment.
 1.26  05-Jun-2010  dholland Rework previous change to fixit() to not trip on option arguments. (Noticed
by wiz.) Clarify the loop logic involved.
 1.25  27-May-2010  dholland Don't recognize "+3" after -- or after the first non-option argument.
This prevents converting "+3" into "-k4.1" in places where getopt
won't recognize it, which in turn prevents silly error messages and
lossage trying to sort files whose names begin with +. PR 43358.
 1.24  06-Nov-2009  joerg Retire __SCCSID. It has only archeological value now. Also retire lint
conditional around __RCSID, lint can handle that fine.
 1.23  10-Sep-2009  dsl Save length of key instead of relying of the weight of the record sep.
This frees a byte value to use for 'end of key' (to correctly sort
short keys) while still having a weight assigned to the field sep.
(Unless -t is given, the field sep is in the field data.)
Do reverse sorts by writing the output file in reverse order (rather
than reversing the sort - apart from merges).
All key compares are now unweighted.
For 'sort -u' mark duplicates keys during the sort and don't write
to the output.
Use -S to mean a posix sort - where equal keys are sorted using the
raw record (rather than being kept in the original order).
For 'sort -f' (no keys) generate a key of the folded data (as for -n
-i and -d), simplifies the code and allows a 'posix' sort.
 1.22  05-Sep-2009  dsl Include a local copy of the sradixsort() code from libc.
Currently unchanged apart from the deletion of the 'unstable' version and
other unneeded code.
Use fldtab[0]. not fldtab-> when we are referring to the global info
in the 0th entry to emphasise that this entry is different.
fldtab[0].weights is only needed in the SINGL_FLD case - so set it there.
Re-indent a big 'if' is setfield() so that the line breaks match the
logic - which looks dubious now!
 1.21  22-Aug-2009  dsl <space> and <tab> at the start of key fields are supposed to be sorted
as if part of the data.
This is a bit fubar since we need a value than sorts before any byte value
as a key field separator - so need 257 byte values (since radixsort() doesn't
take a length for each record).
For now map '\t' to 0x01 and hope no one will notice!
 1.20  22-Aug-2009  dsl Rework the way sort generates sort keys:
- If we generate a key, it is always sortable using memcmp()
- If we are sorting the whole record, then a weight-table must be used
during compares.
- Major surgery to encoding of numbers to ensure unique keys for equal
numeric values. Reverse numerics are handled by inverting the sign.
- Case folding (-f) is handled when the sort keys are generated. No other
code has to care at all.
- Key uniqueness (-u) is done during merge for large datasets. It only
has to be done when writing the output file for small files.
Since the file is in key order this is simple!
Probably fixes all of: PR/27257 PR/25551 PR/22182 PR/31095 PR/30504
PR/36816 PR/37860 PR/39308
Also PR/18614 should no longer die, but a little more work needs to be
done on the merging for very large files.
 1.19  15-Aug-2009  dsl Ansify.
I'm looking at fixing the 'sort -n' fubars, but this code is an
inpeneterable mess - which needs some fixing first!
 1.18  28-Apr-2008  martin branches: 1.18.6; 1.18.12;
Remove clause 3 and 4 from TNF licenses
 1.17  23-Oct-2006  jdolecek branches: 1.17.16;
fix check for field order to allow .0 form in "-k 1.2,1.0"

fix provided in PR bin/25572 by Ross Patterson
 1.16  03-Nov-2004  dsl Add (unsigned char) cast to ctype functions
 1.15  18-Feb-2004  jdolecek insertcol() may insert up to two items to clist, so allocate memory accordingly
this fixes sort regression test 28A and 28B
 1.14  17-Feb-2004  jdolecek fix parsing of some +POS -POS variants, as pointed out by sort regression
tests
 1.13  17-Feb-2004  itojun safer realloc idiom
minor knf
 1.12  15-Feb-2004  jdolecek remove compile-time limit on number of -k options, allocate necessary
structures as-needed
 1.11  15-Feb-2004  jdolecek rewrite fixit() to duplicate less code, and comment the contents better;
also removes compile-time dependancy on ND constant
 1.10  15-Feb-2004  jdolecek g/c redundant setfield() prototype
clear setcolumn() somewhat - use strtol() instead of sscanf(), and
simplify flag setting code
 1.9  07-Aug-2003  jdolecek add TNF copyright
 1.8  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.7  24-Dec-2002  jdolecek add extern definition for ncols and clist[] to sort.h, eliminate extra
definitions in init.c and field.c
g/c MAXMERGE
 1.6  31-Dec-2001  thorpej Change some:

foo += sscanf(++foo, ...);

constructs to:

++foo;
foo += sscanf(foo, ...);

to avoid the following warning from gcc 3.1:

warning: operation on `pos' may be undefined
 1.5  19-Feb-2001  jdolecek Pull up various cosmetic (mostly whitespace) changes from OpenBSD.
This is primarily to ease syncing the two versions.
 1.4  12-Jan-2001  jdolecek use toupper() where appropriate
whitespace/parenthesis police
 1.3  16-Oct-2000  jdolecek cosmetic change: make setcolumn() static, remove bogus redundant setcolumn() prototype
inside setcolumn() function, constify
 1.2  07-Oct-2000  bjh21 Hit sort(1) with a hammer till it compiles.
Also add RCSIDs.
 1.1  07-Oct-2000  bjh21 branches: 1.1.1;
Initial revision
 1.1.1.1  07-Oct-2000  bjh21 4.4BSD-Lite2 contrib/sort
 1.17.16.1  18-May-2008  yamt sync with head.
 1.18.12.1  21-Apr-2010  matt sync to netbsd-5
 1.18.6.1  14-Oct-2009  sborrill Pull up the following revisions(s) (requested by dsl in ticket #1084):
usr.bin/sort/Makefile: revision 1.6-1.8
usr.bin/sort/append.c: revision 1.15-1.22
usr.bin/sort/fields.c: revision 1.20-1.30
usr.bin/sort/files.c: revision 1.27-1.40
usr.bin/sort/fsort.c: revision 1.33-1.45
usr.bin/sort/fsort.h: revision 1.14-1.17
usr.bin/sort/init.c: revision 1.19-1.23
usr.bin/sort/msort.c: revision 1.19-1.28
usr.bin/sort/radix_sort.c: revision 1.1-1.4
usr.bin/sort/sort.1: revision 1.27-1.29
usr.bin/sort/sort.c: revision 1.47-1.56
usr.bin/sort/sort.h: revision 1.20-1.30
usr.bin/sort/tmp.c: revision 1.14-1.15

Only use radix sort for in-memory sort, always merge temporary files.
Use a local radixsort() function so we can pass record length.
Avoid use of weight tables for key compares.
Fix generation of keys for numbers, negate value for reverse sort.
Write file in reverse-key order for 'sort -n'.
'sort -S' now does a posix sort (sort matching keys by record data).
Ensure merge sort doesn't have too many temporary files open.
Fixes: PR#18614 PR#27257 PR#25551 PR#22182 PR#31095 PR#30504 PR#36816
PR#37860 PR#39308 PR#42094
 1.28.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.6.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")

RSS XML Feed