* Copyright (c) 1993 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)append.c 5.1 (Berkeley) %G%";
if ((n = cpos - ppos) > 1) { \
for (; ppos < cpos; ++ppos) \
radixsort(ppos, n, wts1, REC_D); \
for (; ppos < cpos; ppos++) { \
prec = (RECHEADER *) (*ppos - sizeof(TRECHEADER));\
* copy sorted lines to output; check for uniqueness
append(keylist
, nelem
, depth
, fd
, put
, ftbl
)
void (*put
)(RECHEADER
*, FILE *);
register u_char
*wts
, *wts1
;
register u_char
**cpos
, **ppos
, **lastkey
;
register u_char
*cend
, *pend
, *start
;
register struct recheader
*crec
, *prec
;
wts1
= wts
= ftbl
[0].weights
;
if ((!UNIQUE
) && SINGL_FLD
) {
if (ftbl
[0].flags
& F
&& ftbl
[0].flags
& R
)
else if (ftbl
[0].flags
& F
)
lastkey
= keylist
+ nelem
;
depth
+= sizeof(TRECHEADER
);
if (SINGL_FLD
&& (UNIQUE
|| wts1
!= wts
)) {
prec
= (RECHEADER
*) (*ppos
- depth
);
for (cpos
= keylist
+1; cpos
< lastkey
; cpos
++) {
crec
= (RECHEADER
*) (*cpos
- depth
);
if (crec
->length
== prec
->length
) {
pend
= (u_char
*) &prec
->offset
+ prec
->length
;
cend
= (u_char
*) &crec
->offset
+ crec
->length
;
for (start
= *cpos
; cend
>= start
; cend
--) {
if (wts
[*cend
] != wts
[*pend
])
prec
= (RECHEADER
*) (*ppos
- depth
);
for (cpos
= keylist
+1; cpos
< lastkey
; cpos
++) {
crec
= (RECHEADER
*) (*cpos
- depth
);
if (crec
->offset
== prec
->offset
) {
pend
= (u_char
*) &prec
->offset
+ prec
->offset
;
cend
= (u_char
*) &crec
->offset
+ crec
->offset
;
for (start
= *cpos
; cend
>= start
; cend
--) {
if (wts
[*cend
] != wts
[*pend
])
} else for (cpos
= keylist
; cpos
< lastkey
; cpos
++) {
crec
= (RECHEADER
*) (*cpos
- depth
);
* output the already sorted eol bin.
rd_append(binno
, infl0
, nfiles
, outfd
, buffer
, bufend
)
rec
= (RECHEADER
*) buffer
;
if (!getnext(binno
, infl0
, nfiles
, (RECHEADER
*) buffer
, bufend
, 0)) {
while (getnext(binno
, infl0
, nfiles
, (RECHEADER
*) buffer
,
* append plain text--used after sorting the biggest bin.
while ((nread
= fread(buffer
, 1, 4096, b
)) > 0)
EWRITE(buffer
, 1, nread
, a
);