diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-07-20 03:50:28 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-07-20 03:50:28 +0000 |
commit | 23df86474b993f98880fc5d17f2bea3e1c7494be (patch) | |
tree | 0aa05adb208b73cdbc615b09c95e338bc2560893 /usr.bin/sort | |
parent | 2db8f9da625184f46fa73c7f2810ce5fb74879dd (diff) |
ansi; khalek@linuxgamers.net
Diffstat (limited to 'usr.bin/sort')
-rw-r--r-- | usr.bin/sort/append.c | 23 | ||||
-rw-r--r-- | usr.bin/sort/fields.c | 20 | ||||
-rw-r--r-- | usr.bin/sort/files.c | 51 | ||||
-rw-r--r-- | usr.bin/sort/fsort.c | 20 | ||||
-rw-r--r-- | usr.bin/sort/init.c | 30 | ||||
-rw-r--r-- | usr.bin/sort/msort.c | 38 |
6 files changed, 54 insertions, 128 deletions
diff --git a/usr.bin/sort/append.c b/usr.bin/sort/append.c index f191d2bd05f..38797679f1d 100644 --- a/usr.bin/sort/append.c +++ b/usr.bin/sort/append.c @@ -1,4 +1,4 @@ -/* $OpenBSD: append.c,v 1.8 2003/06/03 02:56:16 millert Exp $ */ +/* $OpenBSD: append.c,v 1.9 2004/07/20 03:50:27 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)append.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: append.c,v 1.8 2003/06/03 02:56:16 millert Exp $"; +static char rcsid[] = "$OpenBSD: append.c,v 1.9 2004/07/20 03:50:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -63,13 +63,8 @@ static char rcsid[] = "$OpenBSD: append.c,v 1.8 2003/06/03 02:56:16 millert Exp * copy sorted lines to output; check for uniqueness */ void -append(keylist, nelem, depth, fp, put, ftbl) - u_char **keylist; - int nelem; - int depth; - FILE *fp; - void (*put)(RECHEADER *, FILE *); - struct field *ftbl; +append(u_char **keylist, int nelem, int depth, FILE *fp, + void (*put)(RECHEADER *, FILE *), struct field *ftbl) { u_char *wts, *wts1; int n, odepth; @@ -166,11 +161,8 @@ append(keylist, nelem, depth, fp, put, ftbl) * output the already sorted eol bin. */ void -rd_append(binno, infl0, nfiles, outfp, buffer, bufend) - u_char *buffer, *bufend; - int binno, nfiles; - union f_handle infl0; - FILE *outfp; +rd_append(int binno, union f_handle infl0, int nfiles, FILE *outfp, + u_char *buffer, u_char *bufend) { RECHEADER *rec; @@ -189,8 +181,7 @@ rd_append(binno, infl0, nfiles, outfp, buffer, bufend) * append plain text--used after sorting the biggest bin. */ void -concat(a, b) - FILE *a, *b; +concat(FILE *a, FILE *b) { int nread; char buffer[4096]; diff --git a/usr.bin/sort/fields.c b/usr.bin/sort/fields.c index e6ebcda8d4f..a96038ef4f1 100644 --- a/usr.bin/sort/fields.c +++ b/usr.bin/sort/fields.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fields.c,v 1.9 2003/09/25 02:06:40 tedu Exp $ */ +/* $OpenBSD: fields.c,v 1.10 2004/07/20 03:50:27 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)fields.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: fields.c,v 1.9 2003/09/25 02:06:40 tedu Exp $"; +static char rcsid[] = "$OpenBSD: fields.c,v 1.10 2004/07/20 03:50:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -75,11 +75,8 @@ u_char fnum[NBINS], rnum[NBINS]; * followed by the original line. */ length_t -enterkey(keybuf, line, size, fieldtable) - RECHEADER *keybuf; /* pointer to start of key */ - DBT *line; - int size; - struct field fieldtable[]; +enterkey(RECHEADER *keybuf, /* pointer to start of key */ + DBT *line, int size, struct field fieldtable[]) { int i; u_char *l_d_mask; @@ -135,10 +132,7 @@ enterkey(keybuf, line, size, fieldtable) * constructs a field (as defined by -k) within a key */ u_char * -enterfield(tablepos, endkey, cur_fld, gflags) - struct field *cur_fld; - u_char *tablepos, *endkey; - int gflags; +enterfield(u_char *tablepos, u_char *endkey, struct field *cur_fld, int gflags) { u_char *start, *end, *lineend, *mask, *lweight; struct column icol, tcol; @@ -206,9 +200,7 @@ enterfield(tablepos, endkey, cur_fld, gflags) */ u_char * -number(pos, bufend, line, lineend, Rflag) - u_char *line, *pos, *bufend, *lineend; - int Rflag; +number(u_char *pos, u_char *bufend, u_char *line, u_char *lineend, int Rflag) { int or_sign, parity = 0; int expincr = 1, exponent = -1; diff --git a/usr.bin/sort/files.c b/usr.bin/sort/files.c index 008f0a9bd08..d8592a37b10 100644 --- a/usr.bin/sort/files.c +++ b/usr.bin/sort/files.c @@ -1,4 +1,4 @@ -/* $OpenBSD: files.c,v 1.10 2003/11/15 05:56:28 tedu Exp $ */ +/* $OpenBSD: files.c,v 1.11 2004/07/20 03:50:27 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)files.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: files.c,v 1.10 2003/11/15 05:56:28 tedu Exp $"; +static char rcsid[] = "$OpenBSD: files.c,v 1.11 2004/07/20 03:50:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -52,13 +52,8 @@ static int seq(FILE *, DBT *, DBT *); * It keeps the buffers for all temporary files. */ int -getnext(binno, infl0, nfiles, pos, end, dummy) - int binno; - union f_handle infl0; - int nfiles; - RECHEADER *pos; - u_char *end; - struct field *dummy; +getnext(int binno, union f_handle infl0, int nfiles, RECHEADER *pos, u_char *end, + struct field *dummy) { int i; u_char *hp; @@ -124,13 +119,8 @@ getnext(binno, infl0, nfiles, pos, end, dummy) * in the first fsort pass. */ int -makeline(flno, filelist, nfiles, buffer, bufend, dummy2) - int flno; - union f_handle filelist; - int nfiles; - RECHEADER *buffer; - u_char *bufend; - struct field *dummy2; +makeline(int flno, union f_handle filelist, int nfiles, RECHEADER *buffer, + u_char *bufend, struct field *dummy2) { static u_char *obufend; static size_t osz; @@ -209,12 +199,8 @@ makeline(flno, filelist, nfiles, buffer, bufend, dummy2) * This generates keys. It's only called in the first fsort pass */ int -makekey(flno, filelist, nfiles, buffer, bufend, ftbl) - int flno, nfiles; - union f_handle filelist; - RECHEADER *buffer; - u_char *bufend; - struct field *ftbl; +makekey(int flno, union f_handle filelist, int nfiles, RECHEADER *buffer, + u_char *bufend, struct field *ftbl) { static int fileno = 0; static FILE *dbdesc = 0; @@ -272,10 +258,7 @@ makekey(flno, filelist, nfiles, buffer, bufend, ftbl) * get a key/line pair from fp */ static int -seq(fp, line, key) - FILE *fp; - DBT *line; - DBT *key; +seq(FILE *fp, DBT *line, DBT *key) { static char *buf, flag = 1; char *end, *pos; @@ -317,9 +300,7 @@ seq(fp, line, key) * write a key/line pair to a temporary file */ void -putrec(rec, fp) - RECHEADER *rec; - FILE *fp; +putrec(RECHEADER *rec, FILE *fp) { EWRITE(rec, 1, rec->length + sizeof(TRECHEADER), fp); } @@ -328,9 +309,7 @@ putrec(rec, fp) * write a line to output */ void -putline(rec, fp) - RECHEADER *rec; - FILE *fp; +putline(RECHEADER *rec, FILE *fp) { EWRITE(rec->data+rec->offset, 1, rec->length - rec->offset, fp); } @@ -339,12 +318,8 @@ putline(rec, fp) * get a record from a temporary file. (Used by merge sort.) */ int -geteasy(flno, filelist, nfiles, rec, end, dummy2) - int flno, nfiles; - union f_handle filelist; - RECHEADER *rec; - u_char *end; - struct field *dummy2; +geteasy(int flno, union f_handle filelist, int nfiles, RECHEADER *rec, + u_char *end, struct field *dummy2) { int i; FILE *fp; diff --git a/usr.bin/sort/fsort.c b/usr.bin/sort/fsort.c index 560d83412ef..7a3af24ec9f 100644 --- a/usr.bin/sort/fsort.c +++ b/usr.bin/sort/fsort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsort.c,v 1.10 2004/03/15 13:35:36 sturm Exp $ */ +/* $OpenBSD: fsort.c,v 1.11 2004/07/20 03:50:27 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)fsort.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: fsort.c,v 1.10 2004/03/15 13:35:36 sturm Exp $"; +static char rcsid[] = "$OpenBSD: fsort.c,v 1.11 2004/07/20 03:50:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -61,12 +61,8 @@ extern char *toutpath; int PANIC = FSORTMAX; void -fsort(binno, depth, infiles, nfiles, outfp, ftbl) - int binno, depth; - union f_handle infiles; - int nfiles; - FILE *outfp; - struct field *ftbl; +fsort(int binno, int depth, union f_handle infiles, int nfiles, FILE *outfp, + struct field *ftbl) { u_char *bufend, **keypos, *tmpbuf; u_char *weights; @@ -278,13 +274,7 @@ fsort(binno, depth, infiles, nfiles, outfp, ftbl) */ #define swap(a, b, t) t = a, a = b, b = t void -onepass(a, depth, n, sizes, tr, fp) - u_char **a; - int depth; - long n; - long sizes[]; - u_char *tr; - FILE *fp; +onepass(u_char **a, int depth, long n, long sizes[], u_char *tr, FILE *fp) { size_t tsizes[NBINS+1]; u_char **bin[257], **top[256], ***bp, ***bpmax, ***tp; diff --git a/usr.bin/sort/init.c b/usr.bin/sort/init.c index 66aaa40b49a..ac2f07c1803 100644 --- a/usr.bin/sort/init.c +++ b/usr.bin/sort/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.6 2003/06/26 00:12:39 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.7 2004/07/20 03:50:27 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: init.c,v 1.6 2003/06/26 00:12:39 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.7 2004/07/20 03:50:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -62,8 +62,7 @@ char *setcolumn(char *, struct field *, int); * keep clist in order--inserts a column in a sorted array */ static void -insertcol(field) - struct field *field; +insertcol(struct field *field) { int i; for (i = 0; i < ncols; i++) @@ -90,8 +89,7 @@ insertcol(field) * matches fields with the appropriate columns--n^2 but who cares? */ void -fldreset(fldtab) - struct field *fldtab; +fldreset(struct field *fldtab) { int i; fldtab[0].tcol.p = clist+ncols-1; @@ -111,10 +109,7 @@ fldreset(fldtab) * interprets a column in a -k field */ char * -setcolumn(pos, cur_fld, gflag) - char *pos; - struct field *cur_fld; - int gflag; +setcolumn(char *pos, struct field *cur_fld, int gflag) { struct column *col; int tmp; @@ -147,10 +142,7 @@ setcolumn(pos, cur_fld, gflag) } int -setfield(pos, cur_fld, gflag) - char *pos; - struct field *cur_fld; - int gflag; +setfield(char *pos, struct field *cur_fld, int gflag) { int tmp; cur_fld->weights = ascii; @@ -194,8 +186,7 @@ setfield(pos, cur_fld, gflag) } int -optval(desc, tcolflag) - int desc, tcolflag; +optval(int desc, int tcolflag) { switch(desc) { case 'b': @@ -217,9 +208,7 @@ optval(desc, tcolflag) * Note that the conversion is tricky, see the manual for details. */ void -fixit(argc, argv) - int *argc; - char **argv; +fixit(int *argc, char **argv) { int i, j; long v, w, x; @@ -301,8 +290,7 @@ fixit(argc, argv) * all bets are off. See also num_init in number.c */ void -settables(gflags) - int gflags; +settables(int gflags) { u_char *wts; int i, incr; diff --git a/usr.bin/sort/msort.c b/usr.bin/sort/msort.c index 2891bc7177a..25804c6bbb7 100644 --- a/usr.bin/sort/msort.c +++ b/usr.bin/sort/msort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msort.c,v 1.13 2003/06/26 00:12:39 deraadt Exp $ */ +/* $OpenBSD: msort.c,v 1.14 2004/07/20 03:50:27 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -36,7 +36,7 @@ #if 0 static char sccsid[] = "@(#)msort.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: msort.c,v 1.13 2003/06/26 00:12:39 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: msort.c,v 1.14 2004/07/20 03:50:27 deraadt Exp $"; #endif #endif /* not lint */ @@ -68,13 +68,9 @@ static int cmp(RECHEADER *, RECHEADER *); static int insert(struct mfile **, struct mfile **, int, int); void -fmerge(binno, files, nfiles, get, outfp, fput, ftbl) - union f_handle files; - int binno, nfiles; - int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *); - FILE *outfp; - void (*fput)(RECHEADER *, FILE *); - struct field *ftbl; +fmerge(int binno, union f_handle files, int nfiles, + int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), + FILE *outfp, void (*fput)(RECHEADER *, FILE *), struct field *ftbl) { FILE *tout; int i, j, last; @@ -142,12 +138,9 @@ fmerge(binno, files, nfiles, get, outfp, fput, ftbl) } void -merge(infl0, nfiles, get, outfp, put, ftbl) - int infl0, nfiles; - int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *); - void (*put)(RECHEADER *, FILE *); - FILE *outfp; - struct field *ftbl; +merge(int infl0, int nfiles, + int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), + FILE *outfp, void (*put)(RECHEADER *, FILE *), struct field *ftbl) { int c, i, j; union f_handle dummy = {0}; @@ -198,9 +191,8 @@ merge(infl0, nfiles, get, outfp, put, ftbl) * otherwise just inserts *rec in flist. */ static int -insert(flist, rec, ttop, delete) - struct mfile **flist, **rec; - int delete, ttop; /* delete = 0 or 1 */ +insert(struct mfile **flist, struct mfile **rec, int ttop, + int delete) /* delete = 0 or 1 */ { struct mfile *tmprec; int top, mid, bot = 0, cmpv = 1; @@ -253,10 +245,9 @@ insert(flist, rec, ttop, delete) * check order on one file */ void -order(infile, get, ftbl) - union f_handle infile; - int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *); - struct field *ftbl; +order(union f_handle infile, + int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), + struct field *ftbl) { u_char *crec_end, *prec_end, *trec_end; int c; @@ -306,8 +297,7 @@ order(infile, get, ftbl) } static int -cmp(rec1, rec2) - RECHEADER *rec1, *rec2; +cmp(RECHEADER *rec1, RECHEADER *rec2) { int r; u_char *pos1, *pos2, *end; |