Commit Graph

29 Commits

Author SHA1 Message Date
itojun
ba02466ff9 KNF (mostly whitespace) 2003-10-18 03:03:20 +00:00
enami
d182626b85 Test the value returned by realloc() rather than anything else. 2003-10-17 22:59:35 +00:00
itojun
50847da5c5 safer use of realloc 2003-10-16 06:56:17 +00:00
jdolecek
f84513a754 add TNF copyright 2003-08-07 11:32:34 +00:00
agc
89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
jdolecek
642aec9a6f improve previous slightly - need >= (not just >) in CHECKFSTACK() 2002-12-24 15:15:01 +00:00
jdolecek
b0a6f61876 make sure we don't attempt to write past end of fstack[], error out instead
this fixes second part ('tmpdir get smashed') of bin/18614 by Michael Graff
2002-12-24 14:43:37 +00:00
jdolecek
26eb814987 g/c extern reference to toutpath 2002-10-10 22:41:52 +00:00
enami
d945092654 Use the right file to output merge result. 2002-09-30 05:09:25 +00:00
jdolecek
7fb961dd60 Only try to copy the extra incomplete record data if there is anything
actually read already. Albeit it's not damaging to copy zero data
for bufend == crec->data case, the buffer end could also be between
memory position 'crec' and 'crec->data'. Thus, we could end up with
negative 'bufend - crec->data' value, and obvious havoc.

This change fixes lib/12673, though the problem was masked and no longer
repeatable with the provided example after the recent buffer size bump.
The change was tested with the buffer size change backed off, and really
fixes the problem in the PR.
2001-05-15 11:49:25 +00:00
jdolecek
147b62f6bf fsort(): rearrange the push code to reduce one level of intendation,
free keylist, buffer on end of work; no functional changes
2001-05-15 11:19:45 +00:00
jdolecek
231887cbb4 Bump the initial record buffer size to 1MB and allow it to grow to 8MB,
if needed and record count is within bounds (<MAXNUM), rather than
sorting the input by 64KB chunks. This cuts the number of needed
temporary files considerably (and improves performance, too).
Slighly adjust some #defines, mostly to power of 2 values.

This addresses bin/12673 and bin/12614, as well as complains from other
people.
2001-05-14 21:45:19 +00:00
jdolecek
9c52662e24 fsort(): don't call append() with zero nelem
This fixes the 'sort -f /dev/null' coredump reported on current-users.
2001-02-20 18:33:09 +00:00
jdolecek
affba8f2e9 Pull up various cosmetic (mostly whitespace) changes from OpenBSD.
This is primarily to ease syncing the two versions.
2001-02-19 20:50:17 +00:00
jdolecek
e1a2c672d7 oops - wrong file, backoff local test change 2001-02-19 19:39:53 +00:00
jdolecek
552af1f3f4 enterkey():
* move the test for keybuf size before keypos[-1] assignment, "just in case"
  * move the keypos assignment to improve readability
2001-02-19 19:36:59 +00:00
jdolecek
7f547730fd cosmetic changes - make keylist[] static and remove extern definition
in fsort.h, move macro SALIGN() from sort.h to fsort.c
2001-02-19 19:31:29 +00:00
itojun
eb99cc701b make sure to initialize malloc'ed region. PR 12138. found by malloc.conf=AJ 2001-02-05 14:25:34 +00:00
jdolecek
07eff1f96d use MERGE_FNUM instead of magic value 16 2001-01-19 10:13:21 +00:00
jdolecek
90f3e08483 keep bumping the record buffer up to 8 records - this is to avoid making
excessive number of temporary files for oversized records; the way the
buffer is enlarged is now also safer

initialize 'bufsize' statically, so that the value can be safely used
in e.g. msort.c:fmerge()
2001-01-18 21:40:15 +00:00
itojun
8dd4895415 fix few confusing indentation. XXX still broken 2001-01-13 17:27:21 +00:00
jdolecek
1c216f18ea general cleanup of file list passing:
* get rid of union f_handle, replace by passing explicit int parameter
  and (new) struct filelist
* add new typedefs gen_func_t and put_func_t and use where appropriate
2001-01-11 14:05:24 +00:00
jdolecek
e4de90b20d by default, use stable sort
add -S flag to switch to non-stable sort; for GNU sort compatibility,
provide -s flag too
2001-01-08 18:00:31 +00:00
jdolecek
c477768e0b fix bugs caused by implicit assumption that 'length' and
'offset' members of struct recheader/trecheader are shorts - they are size_t
now
this makes sort pass all tests in TEST/stests again after my last change

other misc cosmetic changes
2000-10-17 15:22:57 +00:00
jdolecek
ab259a291a enlarge line buffer as necessary, so that it's possible
to process lines longer than 65522 characters
constify, rename MAXLLEN to DEFLLEN
2000-10-16 21:53:19 +00:00
jdolecek
681fb9cb36 don't use register declarations 2000-10-15 20:46:33 +00:00
bjh21
e5218d1719 Two classes of changes from the initial OpenBSD commit of this sort(1):
FILE * variables are called "fp" rather than "fd".
Better (safer) temporary-file handling.
2000-10-07 20:37:06 +00:00
bjh21
6029888a3a Hit sort(1) with a hammer till it compiles.
Also add RCSIDs.
2000-10-07 18:37:09 +00:00
bjh21
1d5d9b5b60 4.4BSD-Lite2 contrib/sort 2000-10-07 16:39:34 +00:00