PERFORCE change 140977 for review
Gabor Kovesdan
gabor at FreeBSD.org
Thu May 1 08:59:01 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=140977
Change 140977 by gabor at gabor_server on 2008/05/01 08:58:34
- style(9)
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/sort/append.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/extern.h#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/fields.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/fsort.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/init.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/msort.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/pathnames.h#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/sort.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/sort.h#2 edit
.. //depot/projects/soc2008/gabor_textproc/sort/tmp.c#2 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/sort/append.c#2 (text+ko) ====
@@ -1,5 +1,3 @@
-/* $OpenBSD: append.c,v 1.9 2004/07/20 03:50:27 deraadt Exp $ */
-
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -43,11 +41,11 @@
#endif
#endif /* not lint */
-#include "sort.h"
-
#include <stdlib.h>
#include <string.h>
+#include "sort.h"
+
#define OUTPUT { \
if ((n = cpos - ppos) > 1) { \
for (; ppos < cpos; ++ppos) \
@@ -69,11 +67,11 @@
append(u_char **keylist, int nelem, int depth, FILE *fp,
void (*put)(RECHEADER *, FILE *), struct field *ftbl)
{
- u_char *wts, *wts1;
- int n, odepth;
- u_char **cpos, **ppos, **lastkey;
- u_char *cend, *pend, *start;
- RECHEADER *crec, *prec;
+ u_char *wts, *wts1;
+ int n, odepth;
+ u_char **cpos, **ppos, **lastkey;
+ u_char *cend, *pend, *start;
+ RECHEADER *crec, *prec;
if (*keylist == NULL)
return;
@@ -167,7 +165,7 @@
rd_append(int binno, union f_handle infl0, int nfiles, FILE *outfp,
u_char *buffer, u_char *bufend)
{
- RECHEADER *rec;
+ RECHEADER *rec;
rec = (RECHEADER *) buffer;
if (!getnext(binno, infl0, nfiles, (RECHEADER *) buffer, bufend, 0)) {
@@ -186,8 +184,8 @@
void
concat(FILE *a, FILE *b)
{
- int nread;
- char buffer[4096];
+ int nread;
+ char buffer[4096];
rewind(b);
while ((nread = fread(buffer, 1, 4096, b)) > 0)
==== //depot/projects/soc2008/gabor_textproc/sort/extern.h#2 (text+ko) ====
@@ -1,4 +1,5 @@
/* $OpenBSD: extern.h,v 1.7 2003/06/26 00:12:39 deraadt Exp $ */
+/* $FreeBSD$ */
/*-
* Copyright (c) 1993
@@ -40,11 +41,11 @@
length_t enterkey(RECHEADER *, DBT *, int, struct field *);
void fixit(int *, char **);
void fldreset(struct field *);
-FILE *ftmp(void);
void fmerge(int, union f_handle, int,
int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *),
FILE *, void (*)(RECHEADER *, FILE *), struct field *);
void fsort(int, int, union f_handle, int, FILE *, struct field *);
+FILE *ftmp(void);
int geteasy(int, union f_handle,
int, RECHEADER *, u_char *, struct field *);
int getnext(int, union f_handle,
==== //depot/projects/soc2008/gabor_textproc/sort/fields.c#2 (text+ko) ====
@@ -1,4 +1,5 @@
/* $OpenBSD: fields.c,v 1.13 2008/02/22 01:24:58 millert Exp $ */
+/* $FreeBSD$ */
/*-
* Copyright (c) 1993
@@ -58,21 +59,20 @@
while (pos < lineend && !((FLD_D | REC_D_F) & l_d_mask[*++pos])); \
}
-extern u_char *enterfield(u_char *, u_char *, struct field *, int);
+extern u_char *enterfield(u_char *, u_char *, struct field *, int);
+extern u_char *number(u_char *, u_char *, u_char *, u_char *, int);
-extern u_char *number(u_char *, u_char *, u_char *, u_char *, int);
+extern struct coldesc *clist;
+extern int ncols;
-extern struct coldesc *clist;
-extern int ncols;
+#define DECIMAL '.'
+#define OFFSET 128
-#define DECIMAL '.'
-#define OFFSET 128
+u_char TENS[10]; /* TENS[0] = REC_D <= 128 ? 130 - '0' : 2 -'0'... */
+u_char NEGTENS[10]; /* NEGTENS[0] = REC_D <= 128 ? 126 + '0' : 252 +'0' */
+u_char *OFF_TENS, *OFF_NTENS; /* TENS - '0', NEGTENS - '0' */
+u_char fnum[NBINS], rnum[NBINS];
-u_char TENS[10]; /* TENS[0] = REC_D <= 128 ? 130 - '0' : 2 -'0'... */
-u_char NEGTENS[10]; /* NEGTENS[0] = REC_D <= 128 ? 126 + '0' : 252 +'0' */
-u_char *OFF_TENS, *OFF_NTENS; /* TENS - '0', NEGTENS - '0' */
-u_char fnum[NBINS], rnum[NBINS];
-
/*
* constructs sort key with leading recheader, followed by the key,
* followed by the original line.
@@ -81,13 +81,14 @@
enterkey(RECHEADER *keybuf, /* pointer to start of key */
DBT *line, int size, struct field fieldtable[])
{
- int i;
- u_char *l_d_mask;
- u_char *lineend, *pos;
- u_char *endkey, *keypos;
+ int i;
+ u_char *l_d_mask;
+ u_char *lineend, *pos;
+ u_char *endkey, *keypos;
struct coldesc *clpos;
- int col = 1;
+ int col = 1;
struct field *ftpos;
+
l_d_mask = d_mask;
pos = (u_char *) line->data - 1;
lineend = (u_char *) line->data + line->size-1;
@@ -137,10 +138,10 @@
u_char *
enterfield(u_char *tablepos, u_char *endkey, struct field *cur_fld, int gflags)
{
- u_char *start, *end, *lineend, *mask, *lweight;
+ u_char *start, *end, *lineend, *mask, *lweight;
struct column icol, tcol;
- u_int flags;
- u_int Rflag;
+ u_int flags;
+ u_int Rflag;
icol = cur_fld->icol;
tcol = cur_fld->tcol;
@@ -205,11 +206,11 @@
u_char *
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;
- int bite, expsign = 1, sign = 1, zeroskip = 0;
- u_char lastvalue, *tline, *C_TENS;
- u_char *nweights;
+ int or_sign, parity = 0;
+ int expincr = 1, exponent = -1;
+ int bite, expsign = 1, sign = 1, zeroskip = 0;
+ u_char lastvalue, *tline, *C_TENS;
+ u_char *nweights;
if (Rflag)
nweights = rnum;
@@ -302,7 +303,8 @@
void
num_init(void)
{
- int i;
+ int i;
+
TENS[0] = REC_D <=128 ? 130 - '0' : 2 - '0';
NEGTENS[0] = REC_D <=128 ? 126 + '0' : 254 + '0';
OFF_TENS = TENS - '0';
==== //depot/projects/soc2008/gabor_textproc/sort/fsort.c#2 (text+ko) ====
@@ -1,4 +1,5 @@
/* $OpenBSD: fsort.c,v 1.19 2007/08/21 20:29:25 millert Exp $ */
+/* $FreeBSD$ */
/*-
* Copyright (c) 1993
@@ -50,34 +51,36 @@
* of recursion to keep the head of fstack at 0.
* After PANIC passes, abort to merge sort.
*/
+#include <stdlib.h>
+#include <string.h>
+
#include "sort.h"
#include "fsort.h"
-#include <stdlib.h>
-#include <string.h>
+u_char *linebuf;
+size_t linebuf_size = MAXLLEN;
+struct tempfile fstack[MAXFCT];
-u_char *linebuf;
-size_t linebuf_size = MAXLLEN;
-struct tempfile fstack[MAXFCT];
-#define FSORTMAX 4
+#define FSORTMAX 4
int PANIC = FSORTMAX;
void
fsort(int binno, int depth, union f_handle infiles, int nfiles, FILE *outfp,
struct field *ftbl)
{
- u_char *weights, **keypos, *bufend, *tmpbuf;
- static u_char *buffer, **keylist;
- static size_t bufsize;
- int ntfiles, mfct = 0, total, i, maxb, lastb, panic = 0;
- int c, nelem;
- long sizes[NBINS+1];
- union f_handle tfiles, mstart = {MAXFCT-16};
int (*get)(int, union f_handle, int, RECHEADER *,
- u_char *, struct field *);
- RECHEADER *crec;
- struct field tfield[2];
- FILE *prevfp, *tailfp[FSORTMAX+1];
+ u_char *, struct field *);
+
+ u_char *weights, **keypos, *bufend, *tmpbuf;
+ static u_char *buffer, **keylist;
+ static size_t bufsize;
+ int ntfiles, mfct = 0, total, i, maxb, lastb, panic = 0;
+ int c, nelem;
+ long sizes[NBINS+1];
+ union f_handle tfiles, mstart = {MAXFCT-16};
+ RECHEADER *crec;
+ struct field tfield[2];
+ FILE *prevfp, *tailfp[FSORTMAX+1];
memset(tailfp, 0, sizeof(tailfp));
prevfp = outfp;
@@ -257,13 +260,13 @@
void
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;
- static int histo[256];
- int *hp;
- int c;
- u_char **an, *t, **aj;
- u_char **ak, *r;
+ size_t tsizes[NBINS+1];
+ u_char **bin[257], **top[256], ***bp, ***bpmax, ***tp;
+ static int histo[256];
+ int *hp;
+ int c;
+ u_char **an, *t, **aj;
+ u_char **ak, *r;
memset(tsizes, 0, sizeof(tsizes));
depth += sizeof(TRECHEADER);
==== //depot/projects/soc2008/gabor_textproc/sort/init.c#2 (text+ko) ====
@@ -1,5 +1,3 @@
-/* $OpenBSD: init.c,v 1.11 2007/09/01 18:13:58 kili Exp $ */
-
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -43,17 +41,17 @@
#endif
#endif /* not lint */
-#include "sort.h"
-
#include <ctype.h>
#include <string.h>
+#include "sort.h"
+
extern struct coldesc *clist;
-extern int ncols;
-u_char gweights[NBINS];
+extern int ncols;
+u_char gweights[NBINS];
-static void insertcol(struct field *);
-char *setcolumn(char *, struct field *, int);
+static void insertcol(struct field *);
+char *setcolumn(char *, struct field *, int);
/*
* clist (list of columns which correspond to one or more icol or tcol)
@@ -67,7 +65,8 @@
static void
insertcol(struct field *field)
{
- int i;
+ int i;
+
for (i = 0; i < ncols; i++)
if (field->icol.num <= clist[i].num)
break;
@@ -94,7 +93,8 @@
void
fldreset(struct field *fldtab)
{
- int i;
+ int i;
+
fldtab[0].tcol.p = clist+ncols-1;
for (++fldtab; fldtab->icol.num; ++fldtab) {
for (i = 0; fldtab->icol.num != clist[i].num; i++)
@@ -114,8 +114,8 @@
char *
setcolumn(char *pos, struct field *cur_fld, int gflag)
{
- struct column *col;
- int tmp;
+ struct column *col;
+ int tmp;
col = cur_fld->icol.num ? (&(*cur_fld).tcol) : (&(*cur_fld).icol);
if (sscanf(pos, "%d", &(col->num)) != 1)
@@ -152,7 +152,8 @@
int
setfield(char *pos, struct field *cur_fld, int gflag)
{
- int tmp;
+ int tmp;
+
cur_fld->weights = ascii;
cur_fld->mask = alltable;
pos = setcolumn(pos, cur_fld, gflag);
@@ -218,10 +219,10 @@
void
fixit(int *argc, char **argv)
{
- int i, j, n;
- long v, w, x;
- char *p, *ep;
- char buf[128], *bufp, *bufend;
+ int i, j, n;
+ long v, w, x;
+ char *p, *ep;
+ char buf[128], *bufp, *bufend;
bufend = buf + sizeof(buf);
for (i = 1; i < *argc; i++) {
@@ -299,8 +300,9 @@
void
settables(int gflags)
{
- u_char *wts;
- int i, incr;
+ u_char *wts;
+ int i, incr;
+
for (i=0; i < 256; i++) {
ascii[i] = i;
if (i > REC_D && i < 255 - REC_D+1)
==== //depot/projects/soc2008/gabor_textproc/sort/msort.c#2 (text+ko) ====
@@ -1,5 +1,3 @@
-/* $OpenBSD: msort.c,v 1.21 2007/08/21 20:29:25 millert Exp $ */
-
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -43,39 +41,41 @@
#endif
#endif /* not lint */
-#include "sort.h"
-#include "fsort.h"
-
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "sort.h"
+#include "fsort.h"
+
/* Subroutines using comparisons: merge sort and check order */
-#define DELETE (1)
-#define LALIGN(n) ((n+(sizeof(long)-1)) & ~(sizeof(long)-1))
+#define DELETE (1)
+#define LALIGN(n) ((n+(sizeof(long)-1)) & ~(sizeof(long)-1))
typedef struct mfile {
- u_char *end;
- short flno;
- RECHEADER rec[1];
+ u_char *end;
+ short flno;
+ RECHEADER rec[1];
} MFILE;
-static u_char *wts, *wts1;
-static struct mfile *cfilebuf;
-static void *buffer;
-static size_t bufsize;
+
+static u_char *wts, *wts1;
+static struct mfile *cfilebuf;
+static void *buffer;
+static size_t bufsize;
-static int cmp(RECHEADER *, RECHEADER *);
-static int insert(struct mfile **, struct mfile **, int, int);
+static int cmp(RECHEADER *, RECHEADER *);
+static int insert(struct mfile **, struct mfile **, int, int);
void
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;
- void (*put)(RECHEADER *, FILE *);
- struct tempfile *l_fstack;
+ void (*put)(RECHEADER *, FILE *);
+
+ FILE *tout;
+ int i, j, last;
+ struct tempfile *l_fstack;
wts = ftbl->weights;
if (!UNIQUE && SINGL_FLD && (ftbl->flags & F))
@@ -138,9 +138,9 @@
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};
- struct mfile *flist[16], *cfile;
+ int c, i, j;
+ union f_handle dummy = {0};
+ struct mfile *flist[16], *cfile;
for (i = j = 0; i < nfiles; i++) {
cfile = (MFILE *) (buffer +
@@ -190,8 +190,9 @@
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;
+ struct mfile *tmprec;
+ int top, mid, bot = 0, cmpv = 1;
+
tmprec = *rec;
top = ttop;
for (mid = top/2; bot +1 != top; mid = (bot+top)/2) {
@@ -245,9 +246,9 @@
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;
- RECHEADER *crec, *prec, *trec;
+ u_char *crec_end, *prec_end, *trec_end;
+ int c;
+ RECHEADER *crec, *prec, *trec;
if (bufsize < 2 * ALIGN(MAXLLEN + sizeof(RECHEADER))) {
bufsize = 2 * ALIGN(MAXLLEN + sizeof(RECHEADER));
@@ -292,9 +293,10 @@
static int
cmp(RECHEADER *rec1, RECHEADER *rec2)
{
- int r;
- u_char *pos1, *pos2, *end;
- u_char *cwts;
+ int r;
+ u_char *pos1, *pos2, *end;
+ u_char *cwts;
+
for (cwts = wts; cwts; cwts = (cwts == wts1 ? 0 : wts1)) {
pos1 = rec1->data;
pos2 = rec2->data;
==== //depot/projects/soc2008/gabor_textproc/sort/pathnames.h#2 (text+ko) ====
@@ -1,4 +1,5 @@
/* $OpenBSD: pathnames.h,v 1.2 2003/06/03 02:56:16 millert Exp $ */
+/* $FreeBSD$ */
/*-
* Copyright (c) 1993
@@ -34,4 +35,4 @@
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
*/
-#define _PATH_STDIN "/dev/stdin"
+#define _PATH_STDIN "/dev/stdin"
==== //depot/projects/soc2008/gabor_textproc/sort/sort.c#2 (text+ko) ====
@@ -1,5 +1,3 @@
-/* $OpenBSD: sort.c,v 1.36 2007/08/22 06:56:40 jmc Exp $ */
-
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -52,13 +50,10 @@
* Sort uses radix sort for internal sorting, and allows
* a choice of merge sort and radix sort for external sorting.
*/
-
-#include "sort.h"
-#include "fsort.h"
-#include "pathnames.h"
-
#include <sys/types.h>
#include <sys/stat.h>
+
+#include <err.h>
#include <getopt.h>
#include <locale.h>
#include <paths.h>
@@ -66,34 +61,37 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <err.h>
+
+#include "sort.h"
+#include "fsort.h"
+#include "pathnames.h"
-int REC_D = '\n';
-u_char d_mask[NBINS]; /* flags for rec_d, field_d, <blank> */
+int REC_D = '\n';
+u_char d_mask[NBINS]; /* flags for rec_d, field_d, <blank> */
/*
* weight tables. Gweights is one of ascii, Rascii..
* modified to weight rec_d = 0 (or 255)
*/
-extern u_char gweights[NBINS];
-u_char ascii[NBINS], Rascii[NBINS], RFtable[NBINS], Ftable[NBINS];
+extern u_char gweights[NBINS];
+u_char ascii[NBINS], Rascii[NBINS], RFtable[NBINS], Ftable[NBINS];
/*
* masks of ignored characters. Alltable is 256 ones
*/
-u_char dtable[NBINS], itable[NBINS], alltable[NBINS];
-int SINGL_FLD = 0, SEP_FLAG = 0, UNIQUE = 0, STABLE = 0;
-struct coldesc *clist;
-int ncols = 0;
-int ND = 10; /* limit on number of -k options. */
+u_char dtable[NBINS], itable[NBINS], alltable[NBINS];
+int SINGL_FLD = 0, SEP_FLAG = 0, UNIQUE = 0, STABLE = 0;
+struct coldesc *clist;
+int ncols = 0;
+int ND = 10; /* limit on number of -k options. */
-char *devstdin = _PATH_STDIN;
-char *tmpdir = _PATH_VARTMP;
-char toutpath[PATH_MAX];
+char *devstdin = _PATH_STDIN;
+char *tmpdir = _PATH_VARTMP;
+char toutpath[PATH_MAX];
-static void cleanup(void);
-static void onsig(int);
-static void usage(char *);
+static void cleanup(void);
+static void onsig(int);
+static void usage(char *);
#define CHECK_NFIELDS \
if (++nfields == ND) { \
@@ -106,25 +104,25 @@
static struct option longopts[] = {
{ "ignore-leading-blanks", no_argument, NULL, 'b' },
+ { "check", no_argument, NULL, 'c' },
{ "directory-order", no_argument, NULL, 'd' },
{ "ignore-case", no_argument, NULL, 'f' },
/* XXX: UNIMPLEMENTED
{ "general-numeric-sort", no_argument, NULL, 'g' },
{ "help", no_argument, NULL, 'h' }, */
{ "ignore-nonprinting", no_argument, NULL, 'i' },
+ { "key", required_argument, NULL, 'k' },
/* XXX: UNIMPLEMENTED
{ "month-sort", no_argument, NULL, 'M' }, */
+ { "merge", no_argument, NULL, 'm' },
{ "numric-sort", no_argument, NULL, 'n' },
{ "reverse", no_argument, NULL, 'r' },
- { "check", no_argument, NULL, 'c' },
- { "key", required_argument, NULL, 'k' },
- { "merge", no_argument, NULL, 'm' },
{ "output", required_argument, NULL, 'o' },
- { "stable", no_argument, NULL, 's' },
/* XXX: UNIMPLEMENTED
{ "buffer-size", required_argument, NULL, 'S' }, */
+ { "stable", no_argument, NULL, 's' },
+ { "temporary-directory", required_argument, NULL, 'T' },
{ "field-separator", required_argument, NULL, 't' },
- { "temporary-directory", required_argument, NULL, 'T' },
{ "unique", no_argument, NULL, 'u' },
{ "version", no_argument, NULL, 'v' },
{ "zero-terminated", no_argument, NULL, 'z' },
@@ -134,14 +132,16 @@
int
main(int argc, char *argv[])
{
- int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *);
- int ch, i, stdinflag = 0, tmp = 0;
- char nfields = 0, cflag = 0, mflag = 0;
- char *outfile, *outpath = 0;
- struct field *fldtab, *ftpos;
- union f_handle filelist;
- FILE *outfp = NULL;
- void *p;
+ int (*get)(int, union f_handle, int,
+ RECHEADER *, u_char *, struct field *);
+
+ int ch, i, stdinflag = 0, tmp = 0;
+ char nfields = 0, cflag = 0, mflag = 0;
+ char *outfile, *outpath = 0;
+ struct field *fldtab, *ftpos;
+ union f_handle filelist;
+ FILE *outfp = NULL;
+ void *p;
setlocale(LC_ALL, "");
@@ -171,25 +171,21 @@
fldtab->weights = Rascii;
fldtab->flags |= tmp;
break;
- case 's':
- STABLE = 1;
+ case 'c':
+ cflag = 1;
break;
- case 'o':
- outpath = optarg;
+ case 'H':
+ PANIC = 0;
break;
case 'k':
CHECK_NFIELDS;
setfield(optarg, ++ftpos, fldtab->flags);
break;
- case 't':
- if (SEP_FLAG)
- usage("multiple field delimiters");
- SEP_FLAG = 1;
- d_mask[' '] &= ~FLD_D;
- d_mask['\t'] &= ~FLD_D;
- d_mask[(int)*optarg] |= FLD_D;
- if (d_mask[(int)*optarg] & REC_D_F)
- err(2, "record/field delimiter clash");
+ case 'm':
+ mflag = 1;
+ break;
+ case 'o':
+ outpath = optarg;
break;
case 'R':
if (REC_D != '\n')
@@ -199,21 +195,25 @@
d_mask['\n'] = d_mask[' '];
d_mask[REC_D] = REC_D_F;
break;
+ case 's':
+ STABLE = 1;
+ break;
case 'T':
tmpdir = optarg;
break;
+ case 't':
+ if (SEP_FLAG)
+ usage("multiple field delimiters");
+ SEP_FLAG = 1;
+ d_mask[' '] &= ~FLD_D;
+ d_mask['\t'] &= ~FLD_D;
+ d_mask[(int)*optarg] |= FLD_D;
+ if (d_mask[(int)*optarg] & REC_D_F)
+ err(2, "record/field delimiter clash");
+ break;
case 'u':
UNIQUE = 1;
break;
- case 'c':
- cflag = 1;
- break;
- case 'm':
- mflag = 1;
- break;
- case 'H':
- PANIC = 0;
- break;
case 'v':
printf("FreeBSD sort 5.3.0\n");
exit(0);
@@ -275,7 +275,7 @@
fldtab->weights = gweights;
if (optind == argc) {
- static char *names[2];
+ static char *names[2];
names[0] = devstdin;
names[1] = NULL;
@@ -371,7 +371,7 @@
static void
usage(char *msg)
{
- extern char *__progname;
+ extern char *__progname;
if (msg != NULL)
warnx("%s", msg);
==== //depot/projects/soc2008/gabor_textproc/sort/sort.h#2 (text+ko) ====
@@ -1,4 +1,5 @@
/* $OpenBSD: sort.h,v 1.7 2007/08/21 20:29:25 millert Exp $ */
+/* $FreeBSD$ */
/*-
* Copyright (c) 1993
@@ -45,25 +46,25 @@
#include <stdlib.h>
#include <string.h>
-#define NBINS 256
-#define MAXMERGE 16
+#define NBINS 256
+#define MAXMERGE 16
/* values for masks, weights, and other flags. */
-#define I 1 /* mask out non-printable characters */
-#define D 2 /* sort alphanumeric characters only */
-#define N 4 /* Field is a number */
-#define F 8 /* weight lower and upper case the same */
-#define R 16 /* Field is reversed with respect to the global weight */
-#define BI 32 /* ignore blanks in icol */
-#define BT 64 /* ignore blanks in tcol */
+#define I 1 /* mask out non-printable characters */
+#define D 2 /* sort alphanumeric characters only */
+#define N 4 /* Field is a number */
+#define F 8 /* weight lower and upper case the same */
+#define R 16 /* Field is reversed with respect to the global weight */
+#define BI 32 /* ignore blanks in icol */
+#define BT 64 /* ignore blanks in tcol */
/* masks for delimiters: blanks, fields, and termination. */
-#define BLANK 1 /* ' ', '\t'; '\n' if -T is invoked */
-#define FLD_D 2 /* ' ', '\t' default; from -t otherwise */
-#define REC_D_F 4 /* '\n' default; from -T otherwise */
+#define BLANK 1 /* ' ', '\t'; '\n' if -T is invoked */
+#define FLD_D 2 /* ' ', '\t' default; from -t otherwise */
+#define REC_D_F 4 /* '\n' default; from -T otherwise */
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define max(a, b) ((a) > (b) ? (a) : (b))
#define FCLOSE(file) { \
if (EOF == fclose(file)) \
@@ -78,38 +79,38 @@
/* length of record is currently limited to maximum string length (size_t) */
typedef size_t length_t;
-#define SALIGN(n) ((n+(sizeof(length_t)-1)) & ~(sizeof(length_t)-1))
+#define SALIGN(n) ((n+(sizeof(length_t)-1)) & ~(sizeof(length_t)-1))
/* a record is a key/line pair starting at rec.data. It has a total length
* and an offset to the start of the line half of the pair.
*/
typedef struct recheader {
- length_t length;
- length_t offset;
- u_char data[1];
+ length_t length;
+ length_t offset;
+ u_char data[1];
} RECHEADER;
typedef struct trecheader {
- length_t length;
- length_t offset;
+ length_t length;
+ length_t offset;
} TRECHEADER;
/* This is the column as seen by struct field. It is used by enterfield.
* They are matched with corresponding coldescs during initialization.
*/
struct column {
- struct coldesc *p;
- int num;
- int indent;
+ struct coldesc *p;
+ int num;
+ int indent;
};
/* a coldesc has a number and pointers to the beginning and end of the
* corresponding column in the current line. This is determined in enterkey.
*/
typedef struct coldesc {
- u_char *start;
- u_char *end;
- int num;
+ u_char *start;
+ u_char *end;
+ int num;
} COLDESC;
/* A field has an initial and final column; an omitted final column
@@ -118,24 +119,24 @@
* weights determines the sort weights of a character (from -f, -r).
*/
struct field {
- struct column icol;
- struct column tcol;
- u_int flags;
- u_char *mask;
- u_char *weights;
+ struct column icol;
+ struct column tcol;
+ u_int flags;
+ u_char *mask;
+ u_char *weights;
};
union f_handle {
- int top;
- char **names;
+ int top;
+ char **names;
};
-extern int PANIC; /* maximum depth of fsort before fmerge is called */
-extern u_char ascii[NBINS], Rascii[NBINS], Ftable[NBINS], RFtable[NBINS];
-extern u_char alltable[NBINS], dtable[NBINS], itable[NBINS];
-extern u_char d_mask[NBINS];
-extern int SINGL_FLD, SEP_FLAG, UNIQUE, STABLE;
-extern int REC_D;
-extern char *tmpdir;
-extern int ND; /* limit on number of -k options. */
+extern int PANIC; /* maximum depth of fsort before fmerge is called */
+extern u_char ascii[NBINS], Rascii[NBINS], Ftable[NBINS], RFtable[NBINS];
+extern u_char alltable[NBINS], dtable[NBINS], itable[NBINS];
+extern u_char d_mask[NBINS];
+extern int SINGL_FLD, SEP_FLAG, UNIQUE, STABLE;
+extern int REC_D;
+extern char *tmpdir;
+extern int ND; /* limit on number of -k options. */
#include "extern.h"
==== //depot/projects/soc2008/gabor_textproc/sort/tmp.c#2 (text+ko) ====
@@ -1,5 +1,3 @@
-/* $OpenBSD: tmp.c,v 1.8 2008/03/19 19:25:49 kili Exp $ */
-
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
@@ -57,15 +55,15 @@
#include "sort.h"
#include "pathnames.h"
-#define _NAME_TMP "sort.XXXXXXXXXX"
+#define _NAME_TMP "sort.XXXXXXXXXX"
FILE *
ftmp(void)
{
- sigset_t set, oset;
- FILE *fp;
- int fd;
- char path[PATH_MAX];
+ sigset_t set, oset;
+ FILE *fp;
+ int fd;
+ char path[PATH_MAX];
if (tmpdir[0] == '\0')
errx(2, "invalid temporary directory: \"\"");
More information about the p4-projects
mailing list