/* tree.c 4.1 83/02/11 */
register struct node
*pp
;
register struct index
*qt
, *wt
;
bottom
-> fath
. fp
= pp
;
in
[c
] . flags
= (SEEN
| FBIT
);
d
. integ
= bottom
-> sp
[0] . ch
= pp
-> sp
[1] . ch
;
in
[c
] . fp
= in
[d
. integ
] . fp
= pp
-> sp
[1] . p
= wt
-> pt
= bottom
;
bottom
-> fath
. flags
= (LLEAF
| RLEAF
| FBIT
);
pp
-> fath
. flags
&= ~RLEAF
;
in
[d
. integ
] . flags
= SEEN
;
bottom
-> count
[0] = pp
-> count
[1];
bottom
-> sp
[1] . ch
= c
;
bottom
-> top
[1] = qt
-> next
= wt
;
register struct index
*rt
, *qt
, *st
;
rs
= in
[ch
] . flags
& FBIT
;
sc
= (s
. p
) -> count
[ss
];
st
= (s
. p
) -> top
[ss
];
qc
= (q
. p
) -> count
[qs
];
qt
= (q
. p
) -> top
[qs
];
ts
= (rc
<= t
-> count
[0] ? 1 : 0);
/* exchange pointers of (t, ts) and (r, rs) */
q
. ch
= t
-> sp
[ts
] . ch
; /* { */
s
. ch
= r
-> sp
[rs
] . ch
; /* { */
t
-> sp
[ts
] . ch
= s
. ch
; /* { */
r
-> sp
[rs
] . ch
= q
. ch
; /* { change code when Cory gets v. 7 */
exch (t
, ts
, q
. ch
, r
, rs
); /* { */
exch (r
, rs
, s
. ch
, t
, ts
); /* { */
qs
= (rs
? RLEAF
: LLEAF
);
ss
= (ts
? RLEAF
: LLEAF
);
if (((r
-> fath
. flags
& qs
) << rs
) ^ ((t
-> fath
. flags
& ss
) << ts
)) {
/* create new index at rt */
if (st
) st
-> pt
= s
. p
;
rs
= r
-> fath
. flags
& FBIT
;
if (v
-> fath
. flags
& (vs
? RLEAF
: LLEAF
)) {
in
[x
. ch
] . flags
&= ~01;
if (ws
) in
[x
. ch
] . flags
|= ws
;
(x
. p
) -> fath
. fp
= w
;
(x
. p
) -> fath
. flags
&= ~01;
if (ws
) (x
. p
) -> fath
. flags
|= ws
;