version 1.8, 2000/06/30 16:00:23 |
version 1.9, 2001/02/04 21:27:01 |
|
|
struct tempfile *l_fstack; |
struct tempfile *l_fstack; |
|
|
wts = ftbl->weights; |
wts = ftbl->weights; |
if (!UNIQUE && SINGL_FLD && ftbl->flags & F) |
if (!UNIQUE && SINGL_FLD && (ftbl->flags & F)) |
wts1 = (ftbl->flags & R) ? Rascii : ascii; |
wts1 = (ftbl->flags & R) ? Rascii : ascii; |
if (!cfilebuf) { |
if (!cfilebuf) { |
cfilebuf = malloc(MAXLLEN + sizeof(TMFILE)); |
cfilebuf = malloc(MAXLLEN + sizeof(TMFILE)); |
|
|
struct mfile **flist, **rec; |
struct mfile **flist, **rec; |
int delete, ttop; /* delete = 0 or 1 */ |
int delete, ttop; /* delete = 0 or 1 */ |
{ |
{ |
register struct mfile *tmprec; |
struct mfile *tmprec; |
register int top, mid, bot = 0, cmpv = 1; |
int top, mid, bot = 0, cmpv = 1; |
tmprec = *rec; |
tmprec = *rec; |
top = ttop; |
top = ttop; |
for (mid = top/2; bot +1 != top; mid = (bot+top)/2) { |
for (mid = top/2; bot +1 != top; mid = (bot+top)/2) { |
|
|
int (*get)(); |
int (*get)(); |
struct field *ftbl; |
struct field *ftbl; |
{ |
{ |
u_char *end; |
u_char *crec_end, *prec_end, *trec_end; |
int c; |
int c; |
RECHEADER *crec, *prec, *trec; |
RECHEADER *crec, *prec, *trec; |
|
|
|
|
buffer = malloc(2 * (MAXLLEN + sizeof(TRECHEADER))); |
buffer = malloc(2 * (MAXLLEN + sizeof(TRECHEADER))); |
if (buffer == NULL) |
if (buffer == NULL) |
errx(2, "cannot allocate memory"); |
errx(2, "cannot allocate memory"); |
end = buffer + 2 * (MAXLLEN + sizeof(TRECHEADER)); |
|
crec = (RECHEADER *) buffer; |
crec = (RECHEADER *) buffer; |
|
crec_end = buffer + MAXLLEN + sizeof(TRECHEADER); |
prec = (RECHEADER *) (buffer + MAXLLEN + sizeof(TRECHEADER)); |
prec = (RECHEADER *) (buffer + MAXLLEN + sizeof(TRECHEADER)); |
|
prec_end = buffer + 2 * (MAXLLEN + sizeof(TRECHEADER)); |
wts = ftbl->weights; |
wts = ftbl->weights; |
if (SINGL_FLD && ftbl->flags & F) |
if (SINGL_FLD && (ftbl->flags & F)) |
wts1 = ftbl->flags & R ? Rascii : ascii; |
wts1 = ftbl->flags & R ? Rascii : ascii; |
else |
else |
wts1 = 0; |
wts1 = 0; |
if (get(-1, infile, 1, prec, end, ftbl) == 0) |
if (get(-1, infile, 1, prec, prec_end, ftbl) == 0) |
while (0 == get(-1, infile, 1, crec, end, ftbl)) { |
while (get(-1, infile, 1, crec, crec_end, ftbl) == 0) { |
if (0 < (c = cmp(prec, crec))) { |
if (0 < (c = cmp(prec, crec))) { |
crec->data[crec->length-1] = 0; |
crec->data[crec->length-1] = 0; |
errx(1, "found disorder: %s", |
errx(1, "found disorder: %s", |
|
|
errx(1, "found non-uniqueness: %s", |
errx(1, "found non-uniqueness: %s", |
crec->data+crec->offset); |
crec->data+crec->offset); |
} |
} |
|
/* Swap pointers so that this record is on place |
|
* pointed to by prec and new record is read to place |
|
* pointed to by crec. |
|
*/ |
trec = prec; |
trec = prec; |
prec = crec; |
prec = crec; |
crec = trec; |
crec = trec; |
|
trec_end = prec_end; |
|
prec_end = crec_end; |
|
crec_end = trec_end; |
} |
} |
exit(0); |
exit(0); |
} |
} |
|
|
cmp(rec1, rec2) |
cmp(rec1, rec2) |
RECHEADER *rec1, *rec2; |
RECHEADER *rec1, *rec2; |
{ |
{ |
register int r; |
int r; |
register u_char *pos1, *pos2, *end; |
u_char *pos1, *pos2, *end; |
register u_char *cwts; |
u_char *cwts; |
for (cwts = wts; cwts; cwts = (cwts == wts1 ? 0 : wts1)) { |
for (cwts = wts; cwts; cwts = (cwts == wts1 ? 0 : wts1)) { |
pos1 = rec1->data; |
pos1 = rec1->data; |
pos2 = rec2->data; |
pos2 = rec2->data; |