summaryrefslogtreecommitdiff
path: root/usr.bin/sort/fields.c
AgeCommit message (Collapse)Author
2013-01-20When parsing numbers, allow a leading '+'.apb
2010-12-18Add an 'l' style for sorting that sorts by the string length of the field.christos
2009-11-06Retire __SCCSID. It has only archeological value now. Also retire lintjoerg
conditional around __RCSID, lint can handle that fine.
2009-10-07When encoding numbers, we can use all 8 bits for exponent values.dsl
2009-09-16Minor tweaks to the key generation for numeric fields.dsl
Use 1's compliment for -ve numbers to avoid confitionals.
2009-09-10Save length of key instead of relying of the weight of the record sep.dsl
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.
2009-08-22Fix generation of unmasked alpha keys.dsl
2009-08-22Only process each number digit once.dsl
2009-08-22Rework the way sort generates sort keys:dsl
- 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.
2009-08-20Delete more unwanted/unused cruft.dsl
Simplify logic for reading input records. Do a merge sort whenever we have 16 partial sorted blocks. The patient is breathing, but still carrying a lot of extra weight.
2009-08-15Always add an REC_D char (usually \n) as the last sort key char - wedsl
almost always need one. But do ADD it, instead of overwriting the last byte of the last key since that may be requesting the other end of the sort order. There is no need to check for space for the line after adding the key, but we might as well check before - just to optimise that case. This might fix some of the sort bugs - but not the one I'm looking at!
2009-08-15Remove reference to db.h by using separate ptr+len fields for the onlydsl
structure that used it. Pass end of keybuf area, not size to enterkey() - largely to remove a variable who'se use isn't obvious from the name! The structute of this code sucks.
2009-08-15Ansify.dsl
I'm looking at fixing the 'sort -n' fubars, but this code is an inpeneterable mess - which needs some fixing first!
2009-04-13Fix WARNS=4 issues (-Wcast-qual -Wsign-compare)lukem
2008-04-28Remove clause 3 and 4 from TNF licensesmartin
2004-03-14Do not step over the edge of the buffer (check for '\0'). This just happensheas
to not lose on i386 because another buffer appears immediately following. Regress tests all passed.
2004-02-15make sure zero is recognized as regular number in number(), and thus sortedjdolecek
properly with -n fixes PR bin/20259 by Giles Lean, PR bin/20542 by Peter Seebach, and part of PR bin/24316 by MLH
2004-02-15fix -Wunitialized warningsjdolecek
2003-10-18KNF (mostly whitespace)itojun
2003-08-07add TNF copyrightjdolecek
2003-08-07Move UCB-licensed code from 4-clause to 3-clause licence.agc
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-04-09rename local macro blancmange() to SKIP_BLANKS(), to clarify whatjdolecek
it does and to better signal it might modify it's arguments fixes PR bin/20546 by Peter Seebach
2002-12-24add extern definition for ncols and clist[] to sort.h, eliminate extrajdolecek
definitions in init.c and field.c g/c MAXMERGE
2001-02-19Pull up various cosmetic (mostly whitespace) changes from OpenBSD.jdolecek
This is primarily to ease syncing the two versions.
2001-02-19enterfield(): test the buffer size BEFORE assignment also for the other codejdolecek
branch, since we might get called with tablepos == endkey for some special input files (where an record would happen to fit exactly to the input buffer) - BTW, this bug looks like it has been here ~forever ... This seems to fix the sort crash for 'make british' build of ispell package, as reported by Mark White at current-users@.
2001-02-19enterkey():jdolecek
* move the test for keybuf size before keypos[-1] assignment, "just in case" * move the keypos assignment to improve readability
2001-01-13also remove the clpos++ added in rev 1.4jdolecek
2001-01-13undo broken revision 1.4jdolecek
2001-01-12for stable sort, arrange so that really only relevant part of linejdolecek
is used for sort - this makes sort pass regression test number 36 while here, slighly adjust code formating on couple of places
2000-10-17cosmetic change in way one of for variables is updatedjdolecek
2000-10-15don't use register declarationsjdolecek
2000-10-07Hit sort(1) with a hammer till it compiles.bjh21
Also add RCSIDs.
2000-10-074.4BSD-Lite2 contrib/sortbjh21