Commit Graph

89 Commits

Author SHA1 Message Date
ross 2a76afae02 Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:36:18 +00:00
thorpej 2aa37f4ab3 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
2001-12-31 18:45:04 +00:00
wiz f2058cf3e4 Punctuation nits, sort SEE ALSO. 2001-12-08 19:16:07 +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 266fc04d19 Make compilable with -Wshadow 2001-05-15 11:18:23 +00:00
jdolecek b4f19b2d56 disable the code which maxes nofiles limit, it should not be normally
needed now
2001-05-14 21:52:21 +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
ross 1959d24b79 XXX
For some reason this program wants to open _hundreds_ of temporary files.
Make it setrlimit(RLIMIT_NOFILE, ...), so this rather dubious strategy at
least works well enough to ctag(1) our own kernel.
XXX
2001-04-30 00:25:09 +00:00
fair 5f086f4804 Add cross references for qsort(3), and radixsort(3), per PR 10567 2001-03-16 07:37:58 +00:00
jdolecek d906805397 Use MAXPATHLEN (which is 1024) instead of _POSIX_PATH_MAX (which is only 255).
This change tracks change in rev 1.25 of sort.c by Christos Zoulas.
While here, improve error messages slighly.
2001-02-23 08:59:49 +00:00
christos e56e039c8c - use MAXPATHLEN (1024) instead of _POSIX_PATH_MAX (255) for the temporary
path buffer
- provide better error messages about why the temp file creation is failing
- explicitly compare syscall return to -1 instead of < 0 and fdopen return
  to NULL instead of 0.
2001-02-22 22:45:49 +00:00
christos faf9e3e459 Fix problem when using sort >> foo
If no output file was specified sort fopened("/dev/stdout", "w").
This is *wrong* because "/dev/stdout" will truncate the output file,
thus undoing the append effect the shell had set up. The simple fix
here is to just arrange for outfp = stdout and don't play with /dev/stdout.

While I am here:
	- KNF
	- make pattern for mkstemp have 6 X's.
2001-02-21 19:24:30 +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 025b45e604 Pull in various cosmetic changes from OpenBSD version of this manpage - mostly
whitespace changes, which don't influence the layout of result manpage at all,
but also add -H to SYNOPSIS and state sort(1) appeared in v5, not v6 of
AT&T Unix.
2001-02-19 21:06:57 +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 21928fdd78 enterfield(): test the buffer size BEFORE assignment also for the other code
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-19 19:52:27 +00:00
jdolecek c499b18924 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:41:31 +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
jdolecek 0fbdf074b5 put tmp.c back to Makefile, too 2001-02-19 17:45:24 +00:00
jdolecek 32138e0376 document -T and TMPDIR handling
resurrect ENVIRONMENT and FILES, adjust to be more correct
slighly adjust SYNOPSIS line, so that it looks little nicer :)
2001-02-19 16:27:04 +00:00
jdolecek aa9a452a75 full -T support 2001-02-19 15:53:07 +00:00
jdolecek 5347005ed0 resurrect old ftmp() - it supports alternative directory for temporary
file, which is needed for -T support
2001-02-19 15:45:45 +00:00
jdolecek 1370376fed move sections so that the order is more like the one specified by
mdoc.samples(7)
2001-02-07 21:13:36 +00:00
jdolecek 4f8a23e8ac use -R instead -w, to be compatible with OpenBSD 2001-02-07 21:00:05 +00:00
jdolecek f6b0d130db use -R instead of -w, since that's what OpenBSD is using and there is no reason
to be different
2001-02-07 20:58:09 +00:00
jdolecek eb6e724e72 s/-T/-w/ 2001-02-07 20:32:57 +00:00
jdolecek 14b38a0855 Since -T is used to select directory for temporary files in other sort
implementations, we should avoid using it for something else.
Use (new) flag -w for setting record delimiter, make -T noop.
2001-02-07 20:31:44 +00:00
jdolecek 44f2c62649 use errx(), not err() within section for '-t' flag 2001-02-07 19:47:44 +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 f65ee1b182 merge(): use array of buffers instead of one big buffer for all records, and
enlarge them as necessary to read records from merged files; the buffers
	are allocated once per program run, so there shouldn't be any
	performance difference
This makes sort(1) pass also regression 40B and should make it
fully arbitrary long record capable.
XXX the buffer array could probably be freed on end of fmerge() to save memory
2001-01-19 10:50:31 +00:00
jdolecek 75067b134f adjust intendation 2001-01-19 10:14:31 +00:00
jdolecek 07eff1f96d use MERGE_FNUM instead of magic value 16 2001-01-19 10:13:21 +00:00
jdolecek 553f0c9d4c put MERGE_FNUM here, slighly clean up other defines 2001-01-19 10:12:35 +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
jdolecek 78487dad59 make DEFLLEN plain 1 << 16, don't substract magic value 2001-01-18 21:03:46 +00:00
jdolecek 966f1aeec3 makeline(): make the overflow handling code safe vs. buffer realloc, add
a comment explaining what we do here
2001-01-18 21:02:47 +00:00
jdolecek c690f5dcc8 cosmetic style change 2001-01-18 20:59:43 +00:00
shin 1d9514fbe4 - fix alignment problem. 2001-01-16 12:06:19 +00:00
jdolecek d1fef423d6 set date to when this utility became default system sort(1) on NetBSD
add information about when it came to NetBSD to HISTORY
2001-01-16 10:36:57 +00:00
jdolecek f40f1d2ddf note this sort(1) implementation appeared in 4.4BSD 2001-01-13 21:40:56 +00:00
soren ec09544572 And make usage() test for NULL explicitly.. 2001-01-13 20:21:56 +00:00
soren 7b5f324dcc usage() expects a NULL when there is no specific error message. 2001-01-13 20:20:47 +00:00
jdolecek b36ae8b14a makeline(): put back the memmove(3) removed in rev 1.5 in belief it's been
redundant. "Oops"
This fixes bug reported to me by Simon Burge.
2001-01-13 20:10:52 +00:00
jdolecek 7c5e77a45a also remove the clpos++ added in rev 1.4 2001-01-13 19:04:21 +00:00
jdolecek f4074c5bd3 undo broken revision 1.4 2001-01-13 19:01:14 +00:00
itojun 8dd4895415 fix few confusing indentation. XXX still broken 2001-01-13 17:27:21 +00:00
jdolecek 769f751499 save couple of cycles and bytes by static initialization of sigaction act
and sigtable[]
2001-01-13 11:19:41 +00:00