Commit Graph

81 Commits

Author SHA1 Message Date
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
jdolecek 20db24e8e3 add -s/-S to synopsis
remove TMPDIR stuff - it no longer applies, at least for now
move the note about link/unlink from BUGS to NOTES
add note about trailing record separator and lack of restriction on
line length or allowed bytes
2001-01-13 10:47:29 +00:00
jdolecek f2deab8a4c when merging stuff from several files, make merge handle records correctly
for stable sort so that the records are not swapped arbitrarily - this makes
in-tree BSD sort(1) pass regression test 38

while here, do couple of cleanups, like s/16/MERGE_FNUM/ where appropriate,
making local stuff static and some intendation/code format changes
2001-01-13 10:33:30 +00:00
jdolecek 16b90fdb48 one more warning to kill 2001-01-13 10:17:43 +00:00
jdolecek 7102161857 Since SUS explicitly specifies sort(1) should append a record
delimiter to file if it doesn't end with one, don't warn when this
happens.
2001-01-13 10:07:06 +00:00
jdolecek c0f11cbc8f alltable[], itable[], dtable[] were moved to init.c, g/c from sort.[ch]
put extern declaration for gweights[] to sort.h
2001-01-12 19:41:13 +00:00
jdolecek 341955c93c alltable[], itable[], dtable[] were moved to init.c, g/c from sort.[ch]
put extern declaration for gweights[] to sort.h
add -s/-S to usage(), couple of formating nits
2001-01-12 19:41:12 +00:00
jdolecek 7c2fb292db for stable sort, arrange so that really only relevant part of line
is used for sort - this makes sort pass regression test number 36

while here, slighly adjust code formating on couple of places
2001-01-12 19:39:02 +00:00
jdolecek 59c0b59998 comsetic prototype adjustment 2001-01-12 19:31:25 +00:00