Commit Graph

115 Commits

Author SHA1 Message Date
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
jdolecek adefa598e8 use toupper() where appropriate
whitespace/parenthesis police
2001-01-12 19:30:22 +00:00
jdolecek 43de9457c0 remove #if 0 part 2001-01-12 19:24:42 +00:00
jdolecek 4a22141e02 the g/c in rev 1.12 was too aggressive - put back code
to change file '-' to '/dev/stdin'
2001-01-11 15:10:46 +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 d3a4171066 make ftmp() wrapper aroung tmpfile(), there is no need to reimplement it
move ftmp() from tmp.c to files.c
g/c no longer needed stuff
2001-01-08 19:16:49 +00:00
jdolecek 09bc2d58e8 call setlocale() on startup
reformat the switch contents in main() a little, sort flags by alphabet
where possible
2001-01-08 18:58:56 +00:00
jdolecek af3472c08c constify a bit, small cleanups 2001-01-08 18:35:49 +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
lukem 279552d3db fix up various .Nm abuses:
- keep the case consistent between the actual name and what's referenced.
  e.g, if it's `foo', don't use '.Nm Foo' at the start of a sentence.
- remove unnecessary `.Nm foo' after the first occurrence (except for
  using `.Nm ""' if there's stuff following, or for the 2nd and so on
  occurrences in a SYNOPSIS
- use Sx, Ic, Li, Em, Sq, and Xr as appropriate
2000-11-07 06:43:24 +00:00
jdolecek 374e0e8fff move usr.bin/sort/TEST/stest to regress/usr.bin/sort, add to
regression tests
2000-10-26 23:51: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 fe7f0860c0 order(): since getline()/getnext() behaviour wrt passed
end pointer has changed (full buffer is used instead of first DEFLLEN bytes)
the end pointer cannot be shared for crec and prec, we need to pass
different value in each case
2000-10-17 15:16:27 +00:00
jdolecek 4795d24bfc cosmetic change in way one of for variables is updated 2000-10-17 15:13:40 +00:00
jdolecek f8920e714b put in missing echo for failed test 05G 2000-10-17 14:59:55 +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 b94138e345 include a bit more information in error messages 2000-10-16 21:48:15 +00:00
jdolecek c468ddd4ad include a bit more information in error messages, constify
put temporary files in _PATH_TMP by default
2000-10-16 21:48:14 +00:00
jdolecek ed1fd80898 constify, rename MAXLLEN to DEFLLEN 2000-10-16 21:42:21 +00:00
jdolecek a65a3ad759 cosmetic change: make setcolumn() static, remove bogus redundant setcolumn() prototype
inside setcolumn() function, constify
2000-10-16 21:41:05 +00:00
jdolecek 8fdd463e7a constify, prototype for seq() moved to files.c 2000-10-16 21:38:44 +00:00
jdolecek d3fdb94e73 constify 2000-10-16 21:37:03 +00:00
jdolecek 681fb9cb36 don't use register declarations 2000-10-15 20:46:33 +00:00
bjh21 2a7ec1905b HEAVY formatting cleanup. 2000-10-14 18:48:49 +00:00
thorpej 8035db5770 Format string fixes. 2000-10-11 19:16:39 +00:00
simonb f6518b2053 Include <string.h> to get prototype for memcpy(). Fixed compile problems
on alpha (and other LP64 archs?).

XXX: Can't gcc be fixed so that it doesn't auto-prototype mem*()??
2000-10-07 22:15:29 +00:00
bjh21 2c3ef48b5d OpenBSD revision 1.5:
Normalize treatment of -n option.  Don't know why it was ever special-cased
(since it was broken that way).
2000-10-07 21:46:39 +00:00
bjh21 2594b10381 OpenBSD revision 1.3:
for implied stdin, do not corrupt argv[0]
2000-10-07 21:13:56 +00:00
bjh21 e8234e185c Part of OpenBSD revision 1.2:
Fix err(3) usage.
2000-10-07 21:12:19 +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